Code Monkey home page Code Monkey logo

Comments (3)

AndreRenaud avatar AndreRenaud commented on August 23, 2024

Thanks for the feedback - sounds like a difficult environment to port software to :)

Regarding %g, I think making that change might result in scientific notation output (ie: 3.9265e+2), which I don't think is valid for a PDF. I don't think printf has a precision specifier for %f to tell it to strip trailing zeros unfortunately. Without putting our own special formatter in for this, there doesn't seem to be an easy way to get the desired output.

In general the PDFGen output is not super size optimised, it's more about simplicity & readability (although obviously dropping trailing zeros would benefit both of those if it were easy to implement)

from pdfgen.

mikerayborn avatar mikerayborn commented on August 23, 2024

Thanks Andre. Good point about the possibility of scientific notation in the output. We wouldn't want that in a PDF document. I'm guessing a better solution would be to use a PDF specific formatting routine that could format a floating point number with %f and remove any trailing zeros. I'll have to give that some more thought.

I have to wonder if there will be edge cases in which the use of %g would actually format a float with scientific output for a PDF document. I don't really know, so I have to admit the use of %g would not be the safest thing as different implementations of the standard C library functions could cause it to not work, that is not have scientific notation, in all cases.

Thanks again. I appreciate the feedback. Best Wishes.
--Mike

from pdfgen.

AndreRenaud avatar AndreRenaud commented on August 23, 2024

I'll close this for now then, since it doesn't look like %g is going to work in all cases. Let me know if you want to reopen it or have some other thoughts on the matter.

from pdfgen.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.