Number methods
Although CSML differentiates between Float and Integer, all methods are available on all Number types. Hence, the Number type does not really exist but represents indifferently Float and Integer.
Given the automatic type inference, CSML will automatically try to map integers and floats to whichever type makes more sense in the context.

.pow(Number)

Raise the target integer to the power of the given integer.
1
number.pow(Number) => Number
2
3
// example
4
do val = 3
5
do val.pow(2) // 9
Copied!

.abs()

Return the absolute value of the target number.
1
integer.abs() => Number
2
3
// example
4
do val = -42
5
do val.abs() // 42
Copied!

.cos(), .sin(), .tan()

Return the cosine, sine or tangent of the target number.
1
float.cos() => Float
2
float.sin() => Float
3
4
// example
5
do val = 12.34
6
do val.cos() // 0,9744873988
7
do val.sin() // -0,224442219
8
do val.tan() // -0,2303182363
Copied!

.floor(), .ceil(), .round()

Round the number respectively down, up or using mathematical rounding.
1
float.floor() => Integer
2
float.ceil() => Integer
3
float.round() => Integer
4
5
// example
6
do val = 10.5
7
do val.floor() // 10
8
do val.ceil() // 11
9
do val.round() // 11
Copied!

Last modified 1yr ago