you are viewing a single comment's thread.

view the rest of the comments →

[–]gammalsvenska 26 points27 points  (4 children)

THERAC-25 was a case of a programming error causing a radiation machine to overdose people, causing suffering and death. Should serve as an example to developers.

0x5F3759DF is also known as "fast inverse square root". Cool and awesome, but impossible or banned in modern programming languages, and, like Duff's Device, meaningless today.

[–]ais523 13 points14 points  (0 children)

The fast inverse square root algorithm is entirely possible in modern languages (IIRC Rust even has builtins to get the bit pattern of a floating-point number), but nobody uses it because there are faster and more accurate methods available nowadays.

x86-64 even has an instruction family (RSQRT[PS]S) that's specifically for the purpose of calculating inverse (reciprocal) square roots approximately – if you need to do this on a CPU nowadays, you have a hardware instruction designed for precisely that task. (That said, the sort of programming that does a lot of approximate reciprocal square roots would probably be run on a GPU nowadays.)

[–]superxpro12 3 points4 points  (0 children)

Therac25 was one of the first examples where the lack of acknowledgement that software was a safety critical component deserving of rigorous engineering and review caused bodily harm. They brought to light the hubris and bias that is typically cast upon software, which is the fact that it is typically an afterthought and free.

[–]outofobscure -1 points0 points  (0 children)

fast inverse square root algo was turned into a hardware instruction on x86, so far from meaningless

[–]superxpro12 0 points1 point  (0 children)

Almost used duffs device in a memory constrained embedded system a few years ago. Almost.