From 26cc281390a62be1627edbb7b18fefdeacd687c6 Mon Sep 17 00:00:00 2001 From: Jonas Maebe Date: Sat, 10 Jul 2010 12:15:13 +0000 Subject: [PATCH] * fixed real48 to double conversion for 0.0 (patch by "jeng", mantis #16863) git-svn-id: trunk@15543 - --- .gitattributes | 1 + rtl/inc/genmath.inc | 7 +++++++ tests/webtbs/tw16863.pp | 8 ++++++++ 3 files changed, 16 insertions(+) create mode 100644 tests/webtbs/tw16863.pp diff --git a/.gitattributes b/.gitattributes index 57bb17c496..0e2d4b8ee9 100644 --- a/.gitattributes +++ b/.gitattributes @@ -10527,6 +10527,7 @@ tests/webtbs/tw16803.pp svneol=native#text/plain tests/webtbs/tw1681.pp svneol=native#text/plain tests/webtbs/tw16820.pp svneol=native#text/plain tests/webtbs/tw16861.pp svneol=native#text/plain +tests/webtbs/tw16863.pp svneol=native#text/plain tests/webtbs/tw16874.pp svneol=native#text/plain tests/webtbs/tw1696.pp svneol=native#text/plain tests/webtbs/tw1699.pp svneol=native#text/plain diff --git a/rtl/inc/genmath.inc b/rtl/inc/genmath.inc index 29ebf3a421..fd3d7c3dcf 100644 --- a/rtl/inc/genmath.inc +++ b/rtl/inc/genmath.inc @@ -1403,6 +1403,13 @@ function fpc_int64_to_double(i : int64): double; compilerproc; exponent : word; begin + { check for zero } + if r[0]=0 then + begin + real2double:=0.0; + exit; + end; + { copy mantissa } res[0]:=0; res[1]:=r[1] shl 5; diff --git a/tests/webtbs/tw16863.pp b/tests/webtbs/tw16863.pp new file mode 100644 index 0000000000..8132bacd82 --- /dev/null +++ b/tests/webtbs/tw16863.pp @@ -0,0 +1,8 @@ +var + d : double; + r : real48 = ($0, $0, $0, $0, $0, $0); +BEGIN + d := r; + if d<>0.0 then + halt(1); +END.