From 5f69f5a7cfee0b717d43747935e24a3afb983d3c Mon Sep 17 00:00:00 2001 From: Rika Ichinose Date: Tue, 12 Aug 2025 11:52:29 +0300 Subject: [PATCH] For JVM, use float64xxx wrappers instead of unsupported lvalue casts. --- rtl/inc/genmath.inc | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/rtl/inc/genmath.inc b/rtl/inc/genmath.inc index b0ed3451e2..06080f548b 100644 --- a/rtl/inc/genmath.inc +++ b/rtl/inc/genmath.inc @@ -357,23 +357,32 @@ end; E, ExtraE: int32; begin Mantissa := X; - E := TDoubleRec(X).Exp; + E := {$ifndef jvm} TDoubleRec(X).Exp {$else} float64high(X) shr 20 and (1 shl 11 - 1) {$endif}; if (E > 0) and (E < 2 * TDoubleRec.Bias + 1) then begin // Normal. + {$ifndef jvm} TDoubleRec(Mantissa).Exp := TDoubleRec.Bias - 1; + {$else} + float64sethigh(Mantissa, float64high(Mantissa) and not ((1 shl 11 - 1) shl 20) + (TDoubleRec.Bias - 1) shl 20); + {$endif} Exponent := E - (TDoubleRec.Bias - 1); exit; end; if E = 0 then begin - M := TDoubleRec(X).Frac; + M := {$ifndef jvm} TDoubleRec(X).Frac {$else} uint64(uint32(float64high(X)) and (1 shl 20 - 1)) shl 32 or uint32(float64low(X)) {$endif}; if M <> 0 then begin // Subnormal. ExtraE := 52 - BsrQWord(M); + {$ifndef jvm} TDoubleRec(Mantissa).Frac := M shl ExtraE; // "and (1 shl 52 - 1)" required to remove starting 1, but .SetFrac already does it. TDoubleRec(Mantissa).Exp := TDoubleRec.Bias - 1; + {$else} + float64sethigh(Mantissa, uint32(float64high(Mantissa)) and (1 shl 31) + (TDoubleRec.Bias - 1 - 1 {extra -1 removes starting 1 from M}) shl 20 + uint32(uint64(M shl ExtraE) shr 32)); + float64setlow(Mantissa, uint32(M shl ExtraE)); + {$endif} Exponent := -TDoubleRec.Bias + 2 - ExtraE; exit; end;