# Delphi Tokyo 64-bit flushes denormal numbers to zero?

• A+
Category：Languages

During a short look at the source code of system.math, I discovered that the 64-bit version Delphi Tokyo 10.2.3 flushes denormal IEEE-Doubles to zero, as can be seen from then following program;

``{\$apptype console} uses   system.sysutils, system.math; var   x: double; const   twopm1030 : UInt64 = \$0000100000000000; {2^(-1030)} begin   x := PDouble(@twopm1030)^;   writeln(x);   x := ldexp(1,-515);   writeln(x*x);   x := ldexp(1,-1030);   writeln(x); end. ``

For 32-bit the output is as expected

``8.69169475979376E-0311 8.69169475979376E-0311 8.69169475979376E-0311 ``

but with 64-bit I get

`` 8.69169475979375E-0311  0.00000000000000E+0000  0.00000000000000E+0000 ``

So basically Tokyo can handle denormal numbers in 64-bit mode, the constant is written correctly, but from arithmetic operations or even with ldexp a denormal result is flushed to zero.

Can this observation be confirmed on other systems? If yes, where it is documented? (The only info I could find about zero-flushing is, that `Denormals become zero when stored in a Real48`).

There is only a difference in how the compiler treats the overloaded selection.

If you explicitly define the type for the `LdExp()` first argument like this it works (64-bit):

``program Project116;  {\$APPTYPE CONSOLE} uses   system.sysutils, system.math; var   x: double; const   twopm1030 : UInt64 = \$0000100000000000; {2^(-1030)} begin   x := PDouble(@twopm1030)^;   writeln(x);   x := ldexp(Double(1),-515);   writeln(x*x);   x := ldexp(Double(1),-1030);   writeln(x);   ReadLn; end.  ``

Outputs:

`` 8.69169475979375E-0311  8.69169475979375E-0311  8.69169475979375E-0311 ``

I would say that this behaviour should be reported as a compiler bug, since the overloaded function selected in your case is the `Single` type. The resulting type is a `Double` and the compiler should definitely adapt accordingly.