Remix.run Logo
TZubiri 3 hours ago

You can't "fix" floating point code if you are looking for deterministic answers. You just have to use other data types to handle money or complex mathematical operations like 0.2+0.1, no ifs and buts.

messe 2 hours ago | parent [-]

Floating point is deterministic, what are you talking about?

> You just have to use other data types to handle money or complex mathematical operations like 0.2+0.1

Such as... decimal floating point.

timschmidt 2 hours ago | parent [-]

> Floating point is deterministic, what are you talking about?

Order of operations can change a result, for example. I suspect you mean that the algorithm never changes. While op means that mathematical operations which most folks would expect to be reliable are not.

messe 31 minutes ago | parent [-]

They're not associative, sure. But that's a very far cry from claiming they're non-deterministic.

timschmidt 29 minutes ago | parent [-]

There are enough problems for a 44 page paper titled "What Every Computer Scientist Should Know About Floating-Point Arithmetic"[1] I don't quibble on the language because I know what people mean.

Most folks won't encounter most of the issues, generally. But expose your code to a large enough dataset, or be like me and write a CAD/CAM system with motion control and experience most of them.

That's why I wrote hyperreal[2]

1: https://www.cs.tufts.edu/cs/40/docs/WhatEveryComputerScienti...

2: https://github.com/timschmidt/hyperreal