Wheel IDE

Online demo »

Math, rounding

Math abs, neg example

This gets a random value between greater or equan than 0 and less than 10 and prints the value, the rounded down and rounderd up value in the console.

Code

#project "Math rounding example"

#include "lib/modules/standard.whl"
#include "lib/modules/math.whl"

proc main()
    clearConsole()

    ; Get a random floating point value greater or equal than 0 and less than 10:
    number n = random(1, 99) / 10
    printS("Number:")
    printN(n)

    ; Print the rounded down value in the console:
    printS("Floor:")
    printN(floor(n))

    ; Print the rounded up value in the console:
    printS("Ceil:")
    printN(ceil(n))
end
See also: Modules abs neg