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:
@@ -97,6 +97,15 @@ The natural logarithm of the number.
|
||||
|
||||
Raises this number (the base) to `power`. Returns `nan` if the base is negative.
|
||||
|
||||
### **round**
|
||||
|
||||
Rounds the number to the nearest integer.
|
||||
|
||||
:::wren
|
||||
System.print(1.5.round) //> 2
|
||||
System.print((-3.2).round) //> -3
|
||||
System.print((-3.7).round) //> -4
|
||||
|
||||
### **sin**
|
||||
|
||||
The sine of the number.
|
||||
|
||||
Reference in New Issue
Block a user