this post was submitted on 30 Jun 2024
250 points (96.6% liked)
Programmer Humor
32706 readers
534 users here now
Post funny things about programming here! (Or just rant about your favourite programming language.)
Rules:
- Posts must be relevant to programming, programmers, or computer science.
- No NSFW content.
- Jokes must be in good taste. No hate speech, bigotry, etc.
founded 5 years ago
MODERATORS
you are viewing a single comment's thread
view the rest of the comments
view the rest of the comments
Correct, JSON can handle any precision, because it's just dumped as a string anyway, just not enclosed in the
""
. However, as you mentioned, as soon as it comes through the parser it'll put it into an underlying float value. In C# I create a save high precision attribute that will take the value and put it directly into adecimal
. In JS I'm sure there's some way to do that, but that parser is way less extensible compared to C#. However, this also all assumes you know the client will parse it correctly, overriding the default behavior. Safest is to just send it as a string, and then create your parsers to automatically send to and from strings