Giter VIP home page Giter VIP logo

Comments (3)

artwyman avatar artwyman commented on July 20, 2024

Hi @seewalker. That kind of a templated approach to generic integers seems doable, but out of scope for json11. Support only for specific numeric types was an early design decision which is explained in a comment here: https://github.com/dropbox/json11/blob/master/json11.hpp#L16

In the interest of maximal compatibility, json11 will implicitly take the number types which it knows are compatible, and require the user to perform explicit casts in cases where truncation/rounding might be necessary.

from json11.

seewalker avatar seewalker commented on July 20, 2024

Thanks for the answer. A remark for anybody who visits this page with the same thoughts I had: as mentioned in the link pretty much any number type can be safely cast as a double so that's the lowest-common denominator solution that makes sense.

from json11.

artwyman avatar artwyman commented on July 20, 2024

That's true for most number types, but be cautious that it's not necessarily safe for a 64-bit (or larger) integer (because a double contains only 53 bits of precision, so would need to round), or for a long double (which would also need to round).

from json11.

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.