this post was submitted on 25 Sep 2024
-53 points (7.9% liked)

Programming

17080 readers
271 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 !webdev@programming.dev



founded 1 year ago
MODERATORS
 

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
[–] aubeynarf@lemmynsfw.com 2 points 3 days ago* (last edited 3 days ago) (5 children)

JavaScript is truly a bizarre language - we don’t need to go as far as arbitrary-precision decimal, it does not even feature integers.

I have to wonder why it ever makes the cut as a backend language.

[–] luciole@beehaw.org 1 points 3 days ago (1 children)

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.

[–] aubeynarf@lemmynsfw.com 1 points 3 days ago (1 children)

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.

[–] luciole@beehaw.org 1 points 3 days ago* (last edited 3 days ago) (1 children)

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

[–] aubeynarf@lemmynsfw.com 3 points 3 days ago* (last edited 3 days 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

load more comments (3 replies)