RosettaCodeData/Task/Extreme-floating-point-values/D/extreme-floating-point-values-2.d

14 lines
444 B
D
Raw Permalink Normal View History

2013-04-10 16:57:12 -07:00
import std.math: FloatingPointControl;
void main() {
// Enable hardware exceptions for division by zero, overflow
// to infinity, invalid operations, and uninitialized
// floating-point variables.
FloatingPointControl fpc;
fpc.enableExceptions(FloatingPointControl.severeExceptions);
double f0 = 0.0;
double y1 = f0 / f0; // generates hardware exception
// unless it's compiled with -O)
}