A Philosophy of Software Design

FinalEvilution FinalEvilution at gmail.com
Sun Jun 28 19:31:35 UTC 2026


On Sunday, 28 June 2026 at 15:50:04 UTC, Forum User wrote:

> If you write a program which influences political decision 
> making you should favor crashing over giving poor advise.

I'd just like to note that there are floating point hardware 
exceptions 
[FloatingPointControl](https://dlang.org/phobos/std_math_hardware.html#.FloatingPointControl)
that can be used. With caveats.
No stacktrace, just a coredump. Gotta use gdb to get it.
No crash when using an uninitialized variable even tho the docs 
say it should. Bug? "Note in particular that if invalidException 
is enabled, a hardware trap will be generated whenever an 
uninitialized floating-point variable is used."

```
import std.stdio;
import std.math.hardware;

void main()
{
     FloatingPointControl fpctrl;
     fpctrl.enableExceptions(FloatingPointControl.allExceptions);
     writeln(foo(0));
}

float foo(float input)
{
     float nan;
     return 1/input;
     //return nan/input; // No floating point exception. Bug?
}
```


More information about the Digitalmars-d mailing list