|
import "math" for Math
|
|
|
|
System.print((Math.sin(0) - 0).abs < 0.0001) // expect: true
|
|
System.print((Math.cos(0) - 1).abs < 0.0001) // expect: true
|
|
System.print((Math.tan(0) - 0).abs < 0.0001) // expect: true
|
|
|
|
System.print((Math.sqrt(4) - 2).abs < 0.0001) // expect: true
|
|
System.print((Math.sqrt(9) - 3).abs < 0.0001) // expect: true
|
|
|
|
System.print((Math.pow(2, 3) - 8).abs < 0.0001) // expect: true
|
|
System.print((Math.pow(3, 2) - 9).abs < 0.0001) // expect: true
|
|
|
|
System.print((Math.log(Math.e) - 1).abs < 0.0001) // expect: true
|
|
System.print((Math.exp(1) - Math.e).abs < 0.0001) // expect: true
|
|
|
|
System.print(Math.floor(3.7)) // expect: 3
|
|
System.print(Math.ceil(3.2)) // expect: 4
|
|
System.print(Math.round(3.5)) // expect: 4
|
|
System.print(Math.round(3.4)) // expect: 3
|
|
|
|
System.print(Math.abs(-5)) // expect: 5
|
|
System.print(Math.abs(5)) // expect: 5
|
|
|
|
System.print(Math.min(3, 7)) // expect: 3
|
|
System.print(Math.max(3, 7)) // expect: 7
|
|
System.print(Math.clamp(5, 0, 10)) // expect: 5
|
|
System.print(Math.clamp(-5, 0, 10)) // expect: 0
|
|
System.print(Math.clamp(15, 0, 10)) // expect: 10
|
|
|
|
System.print((Math.pi - 3.14159).abs < 0.001) // expect: true
|
|
System.print((Math.e - 2.71828).abs < 0.001) // expect: true
|
|
|
|
System.print(Math.sign(5)) // expect: 1
|
|
System.print(Math.sign(-5)) // expect: -1
|
|
System.print(Math.sign(0)) // expect: 0
|
|
|
|
System.print(Math.lerp(0, 10, 0.5)) // expect: 5
|