Fix rounding issues introduced by SANE bug workarounds.

The lrint functions could give the wrong result for negative numbers in upward/downward rounding modes. Casts to comp could also have different rounding behavior.
This commit is contained in:
Stephen Heumann 2021-11-30 20:19:57 -06:00
parent b6690c4826
commit b01800ff77
3 changed files with 19 additions and 4 deletions

View File

@ -81,6 +81,12 @@ fpextra private dummy segment
****************************************************************
*
~CompPrecision start
tsc round to integer
clc
adc #4
pea 0
pha
FRINTX
lda 4+8,s
pha save original sign
asl a force sign to positive

View File

@ -34,3 +34,9 @@
LDX #$090A
JSL $E10000
MEND
MACRO
&LAB FRINTX
&LAB PEA $0014
LDX #$090A
JSL $E10000
MEND

View File

@ -1136,17 +1136,20 @@ lrintl entry
csubroutine (10:x),0
pei x+8 save sign of x
asl x+8 x = abs(x)
lsr x+8
tdc convert to integer
tdc
clc
adc #x
pea 0
pha
pea 0
pha
FX2C
pea 0
pha
FRINTX round x to integer
asl x+8 x = abs(x)
lsr x+8
FX2C convert to comp
lda x+4 if x is out of range of long
ora x+6