feat: implement floating-point number literal parsing and arithmetic operations
Add support for floating-point number literals in the parser by detecting decimal points with trailing digits in `readNumber()`, and switch the compiler's `number()` function from `strtol` to `strtod` for proper double conversion. Update the `num_abs` primitive to use `fabs()` instead of manual negation. Extend test coverage across arithmetic, comparison, equality, modulus, and string conversion tests with floating-point cases, and add a new test for decimal point at end-of-file error detection.
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
io.write(8 / 2) // expect: 4
|
||||
io.write(8 / 2) // expect: 4
|
||||
io.write(12.34 / -0.4) // expect: -30.85
|
||||
|
||||
// TODO(bob): Floating point numbers.
|
||||
// TODO(bob): Unsupported RHS types.
|
||||
// TODO(bob): Divide by zero.
|
||||
|
||||
Reference in New Issue
Block a user