I am surprised not the get division by zero exception. How do I get it back?
Berlin 10.1 very recent install, new project,
procedure TForm1.Button1Click(Sender: TObject);
var
a: Double;
begin
a := 5/0; // No exception
ShowMessage(a.ToString); // -> 'INF'
end;
a := 5/0;
The expression 5/0
is, in technical language terms, a constant expression.
A constant expression is an expression that the compiler can evaluate without executing the program in which it occurs. Constant expressions include numerals; character strings; true constants; values of enumerated types; the special constants True, False, and nil; and expressions built exclusively from these elements with operators, typecasts, and set constructors.
As such this expression is evaluated by the compiler, and not at runtime. So its evaluation is determined by compile time rules and cannot be influenced by runtime floating point unit exception masks.
And those rules state that positive value divided by zero is equal to +INF
, a special IEEE754 value. If you change the expression to have at least one argument that is not a constant expression then it will be evaluated at runtime, and a divide by zero exception will be raised.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With