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,6 +1,10 @@
|
||||
io.write(123) // expect: 123
|
||||
io.write(987654) // expect: 987654
|
||||
io.write(0) // expect: 0
|
||||
io.write(-0) // expect: 0
|
||||
io.write(123) // expect: 123
|
||||
io.write(987654) // expect: 987654
|
||||
io.write(0) // expect: 0
|
||||
io.write(-0) // expect: -0
|
||||
|
||||
// TODO(bob): Floating point numbers.
|
||||
io.write(123.456) // expect: 123.456
|
||||
io.write(-0.001) // expect: -0.001
|
||||
|
||||
// TODO(bob): Hex? Scientific notation?
|
||||
// TODO(bob): Literals at and beyond numeric limits.
|
||||
|
||||
Reference in New Issue
Block a user