-51
submitted 2 days ago by [email protected] to c/[email protected]

Have you performed simple arithmetic operations like 0.1 + 0.2? You might have gotten something strange: 0.1 + 0.2 = 0.30000000000000004.

you are viewing a single comment's thread
view the rest of the comments
[-] [email protected] 1 points 1 day ago

The JavaScript Number type is implemented as an IEEE 754 double and as such any integer between -2^53^ and 2^53^ are represented without loss of precision. I can’t say I’ve ever missed explicitly declaring a value as an integer in JS. It’s dynamically typed anyways. There’s the languages people complain about and the ones nobody uses.

[-] [email protected] 1 points 1 day ago

And then JSON doesn’t restrict numbers to any range or precision; and at least when I deal with JSON values, I feel the need to represent them as a BigDecimal or similar arbitrary precision type to ensure I am not losing information.

[-] [email protected] 1 points 1 day ago* (last edited 1 day ago)

I hope you work in a field where worrying about your integers hitting larger values than 9 quadrillion is justified.

[-] [email protected] 3 points 1 day ago* (last edited 1 day ago)

Could be a crypto key, or a randomly distributed 64-bit database row ID, or a memory offset in a stack dump of a 64 bit program

this post was submitted on 25 Sep 2024
-51 points (8.2% liked)

Programming

17071 readers
384 users here now

Welcome to the main community in programming.dev! Feel free to post anything relating to programming here!

Cross posting is strongly encouraged in the instance. If you feel your post or another person's post makes sense in another community cross post into it.

Hope you enjoy the instance!

Rules

Rules

  • Follow the programming.dev instance rules
  • Keep content related to programming in some way
  • If you're posting long videos try to add in some form of tldr for those who don't want to watch videos

Wormhole

Follow the wormhole through a path of communities [email protected]



founded 1 year ago
MODERATORS