this post was submitted on 24 Sep 2025
99 points (97.1% liked)

Programming

22883 readers
182 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 2 years ago
MODERATORS
you are viewing a single comment's thread
view the rest of the comments
[–] randy@lemmy.ca 16 points 4 days ago* (last edited 4 days ago) (5 children)

I got hung up on this line:

This requires deterministic math with explicit rounding modes and precision, not the platform-dependent behavior you get with floats.

Aren't floats mostly standardized these days? The article even mentions that standard. Has anyone here seen platform-dependent float behaviour?

Not that this affects the article's main point, which is perfectly reasonable.

[–] nimpnin@sopuli.xyz 24 points 4 days ago

Mostly standardized? Maybe. What I know is that float summation is not associative, which means that things that are supposed to be equal (x + y + z = y + z + x) are not necessarily that for floats.

[–] KRAW@linux.community 22 points 4 days ago

The IEEE standard actually does not dictate a rounding policy

[–] a1studmuffin@aussie.zone 12 points 4 days ago (1 children)

Floating-Point Determinism | Random ASCII - tech blog of Bruce Dawson https://randomascii.wordpress.com/2013/07/16/floating-point-determinism/

The short answer to your questions is no, but if you're careful you can prevent indeterminism. I've personally ran into it encoding audio files using the Opus codec on AMD vs Intel processors (slightly different binary outputs for the exact same inputs). But if you're able to control your dev environment from platform choice all the way down to the assembly instructions being used, you can prevent it.

[–] randy@lemmy.ca 4 points 4 days ago

Thanks, that's an excellent article, and it's exactly what I was looking for.

[–] pinball_wizard@lemmy.zip 2 points 4 days ago

The real standard is whatever Katherine in accounting got out of the Excel nightmare sheets they reconcile against.

[–] bleistift2@sopuli.xyz 0 points 4 days ago* (last edited 4 days ago) (2 children)

If you count the programming language you use as ‘platform’, then yes. Python rounds both 11.5 and 12.5 to 12.

[–] WolfLink@sh.itjust.works 4 points 4 days ago

This is a common rounding strategy because it doesn’t consistently overestimate like the grade school rounding strategy of always rounding up does.

[–] FizzyOrange@programming.dev 2 points 3 days ago

That is default IEEE behaviour: https://en.wikipedia.org/wiki/Rounding#Rounding_half_to_even

This is the default rounding mode used in IEEE 754 operations for results in binary floating-point formats.

Though it's definitely a bad default because it's so surprising. Javascript and Rust do not do this.

Not really anything to do with determinism though.