feat: add Num.round method for rounding numbers to nearest integer
Implement the `round` method on the Num class that rounds a number to the nearest integer using standard rounding rules (away from zero for .5). The implementation adds a new `num_round` primitive function in the VM core, registers it as a method on the Num class, includes documentation in the core module reference, and adds a comprehensive test file covering positive, negative, zero, and fractional cases.
This commit is contained in:
@@ -0,0 +1,8 @@
|
||||
System.print(123.round) // expect: 123
|
||||
System.print((-123).round) // expect: -123
|
||||
System.print(0.round) // expect: 0
|
||||
System.print((-0).round) // expect: -0
|
||||
System.print(0.123.round) // expect: 0
|
||||
System.print(12.3.round) // expect: 12
|
||||
System.print((-0.123).round) // expect: -0
|
||||
System.print((-12.3).round) // expect: -12
|
||||
Reference in New Issue
Block a user