Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Numbers

NaijaScript numbers are IEEE-754 floating point values that can represent both integers and decimals.

Literals

Declare numeric values:

make foo get 42
make bar get 3.14
make baz get minus 2.5

Methods

Available methods and return types:

MethodDescriptionReturns
abs()Absolute valueNumber
sqrt()Square rootNumber
floor()Round down to the nearest integerNumber
ceil()Round up to the nearest integerNumber
round()Round to the nearest integerNumber

Examples

Call methods on literals and variables:

make foo get (minus 3.5).abs()
make bar get 9.0.sqrt()
make baz get 2.7.floor()

Use methods on variables and chain calls:

make foo get minus 2.5
make bar get foo.abs()
make baz get (minus 2.5).abs().sqrt()

Operators

Available arithmetic operators:

OperatorDescription
addAddition
minusSubtraction
timesMultiplication
divideDivision
modModulo