1
0
mirror of https://github.com/cc65/cc65.git synced 2024-06-09 06:29:38 +00:00

fix scanning the fractional digits of a float

This commit is contained in:
mrdudz 2022-06-15 23:04:57 +02:00
parent 5aa75ae81f
commit 6a35bfd2fa

View File

@ -629,14 +629,17 @@ static void NumericConst (void)
NextChar ();
/* Read fractional digits */
Scale = FP_D_Make (1.0);
Scale = FP_D_Make (10.0);
while (IsXDigit (CurC) && (DigitVal = HexVal (CurC)) < Base) {
/* Get the value of this digit */
Double FracVal = FP_D_Div (FP_D_FromInt (DigitVal * Base), Scale);
Double FracVal = FP_D_FromInt(0);
if (DigitVal != 0) {
FracVal = FP_D_Div (FP_D_FromInt (DigitVal), Scale);
}
/* Add it to the float value */
FVal = FP_D_Add (FVal, FracVal);
/* Scale base */
Scale = FP_D_Mul (Scale, FP_D_FromInt (DigitVal));
Scale = FP_D_Mul (Scale, FP_D_FromInt (Base));
/* Skip the digit */
NextChar ();
}