Mercurial > hg > index.cgi
changeset 95:25b44f1ac2aa
Fix detection of integer value on ascii conversion
author | William Astle <lost@l-w.ca> |
---|---|
date | Sun, 22 Oct 2023 21:03:24 -0600 |
parents | 5fa8c479dbf7 |
children | 69af7224f614 |
files | src/number.s |
diffstat | 1 files changed, 9 insertions(+), 7 deletions(-) [+] |
line wrap: on
line diff
--- a/src/number.s Sun Oct 22 17:25:16 2023 -0600 +++ b/src/number.s Sun Oct 22 21:03:24 2023 -0600 @@ -239,14 +239,16 @@ ; Normalization is not required here though rounding might be. Rounding will be handled during floating point return. ; By ensuring there were no leading zeroes converted, the result is already pre-normalized without losing precision due ; to an aribtrary number of leading zeroes. -val_parsenum11a cmpb fpaextra ; is the exponent less than the number of digits? - blt val_parsenum13 ; brif so - return floating point (signed comparison!) - cmpb #10 ; is exponent in the range for a binary integer? - bgt val_parsenum13 ; brif not - return floating point +val_parsenum11a cmpb #9 ; is the exponent greater than possible for a 32 bit integer? + bgt val_parsenum13 + lda fpaextra ; fetch the number of digits + deca ; account for the decimal point offset + cmpa fpa0+fpa.exp ; do we have more digits than the exponent (fractional)? + bgt val_parsenum13 ; brif we have more digits than exponent ; Compare with 2147483648, the maximum *negative* value; note that this is a floating point comparison because we ; already normalized everything above and it handles exponents properly - lda fpa0+fpa.exp ; compare exponents (unbiased), exponent adjusted for above code - cmpa #10 + lda fpa0+fpa.exp ; compare exponents (unbiased) + cmpa #9 bne val_parsenum12 ldx fpa0+fpa.sig ; compare top of significand cmpx #0x2147 @@ -269,7 +271,7 @@ jmp fps_normalize val_parsenum14 lda #valtype_int ; set value type to integer sta val0+val.type - ldb #10 ; exponent needed for decimal point to the right of significand + ldb #9 ; exponent needed for decimal point to the right of significand subb fpa0+fpa.exp ; number of digit shifts needed to denormalize beq val_parsenum16 ; brif already denormalized lslb ; do 4 shifts per digit