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:
Bob Nystrom
2013-11-10 05:32:57 +00:00
parent c430056f70
commit 0ea34e00fe
14 changed files with 64 additions and 33 deletions
+3 -3
View File
@@ -1,5 +1,5 @@
io.write(5 - 3) // expect: 2
io.write(3 - 2 - 1) // expect: 0
io.write(5 - 3) // expect: 2
io.write(3.1 - 0.24) // expect: 2.86
io.write(3 - 2 - 1) // expect: 0
// TODO(bob): Floating point numbers.
// TODO(bob): Unsupported RHS types.