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:
parent
b6690c4826
commit
b01800ff77
|
@ -81,6 +81,12 @@ fpextra private dummy segment
|
||||||
****************************************************************
|
****************************************************************
|
||||||
*
|
*
|
||||||
~CompPrecision start
|
~CompPrecision start
|
||||||
|
tsc round to integer
|
||||||
|
clc
|
||||||
|
adc #4
|
||||||
|
pea 0
|
||||||
|
pha
|
||||||
|
FRINTX
|
||||||
lda 4+8,s
|
lda 4+8,s
|
||||||
pha save original sign
|
pha save original sign
|
||||||
asl a force sign to positive
|
asl a force sign to positive
|
||||||
|
|
|
@ -34,3 +34,9 @@
|
||||||
LDX #$090A
|
LDX #$090A
|
||||||
JSL $E10000
|
JSL $E10000
|
||||||
MEND
|
MEND
|
||||||
|
MACRO
|
||||||
|
&LAB FRINTX
|
||||||
|
&LAB PEA $0014
|
||||||
|
LDX #$090A
|
||||||
|
JSL $E10000
|
||||||
|
MEND
|
||||||
|
|
11
math2.asm
11
math2.asm
|
@ -1136,17 +1136,20 @@ lrintl entry
|
||||||
csubroutine (10:x),0
|
csubroutine (10:x),0
|
||||||
|
|
||||||
pei x+8 save sign of x
|
pei x+8 save sign of x
|
||||||
asl x+8 x = abs(x)
|
|
||||||
lsr x+8
|
|
||||||
|
|
||||||
tdc convert to integer
|
tdc
|
||||||
clc
|
clc
|
||||||
adc #x
|
adc #x
|
||||||
pea 0
|
pea 0
|
||||||
pha
|
pha
|
||||||
pea 0
|
pea 0
|
||||||
pha
|
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
|
lda x+4 if x is out of range of long
|
||||||
ora x+6
|
ora x+6
|
||||||
|
|
Loading…
Reference in New Issue