Trunc () error for high performance Int64 for 64-bit builds

Why does the following code fail for 64-bit builds (but works for 32-bit builds)?

var
  TruncTmp: Extended;
begin
  TruncTmp := 9223372036854775296;
  TruncTmp := Trunc(TruncTmp); // this fails on 64-bit
  Assert(TruncTmp = 9223372036854775296);
end;

The first random exception is $ 0000000000405D70. The exception class is $ C0000090 with the message 'c0000090 FLOAT_INVALID_OPERATION'.

Is this a mistake or am I missing something?

Notes:

  • I am using Delphi 10.2
  • Numbers < 9223372036854775296working fine
+4
source share
1 answer

In Win64 there is no "extended" (80-bit FP) type - it is simply an alias of "double" (64-bit FP). Thus, you only have 53-bit resolution twice.

So, I think this is as expected in your case.

+12
source

Source: https://habr.com/ru/post/1692308/


All Articles