-
Notifications
You must be signed in to change notification settings - Fork 8
Expand file tree
/
Copy pathNumber.strict
More file actions
112 lines (112 loc) · 2.35 KB
/
Number.strict
File metadata and controls
112 lines (112 loc) · 2.35 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
has iterator
constant Epsilon = 0.00001
to Text
5 to Text is "5"
10.1 to Text is "10.1"
for digits
value to Character
digits Numbers
1.digits is (1)
123.digits is (1, 2, 3)
let nextPart = (value / 10).Floor
let currentDigit = value % 10
nextPart is 0 then currentDigit else nextPart.digits + currentDigit
to Character
5 to Character is "5"
constant canOnlyConvertSingleDigit = Error
10 to Character is canOnlyConvertSingleDigit
value is in Range(0, 10) then Character(Character.zeroCharacter + value) else canOnlyConvertSingleDigit(value)
Floor Number
1.Floor is 1
2.4.Floor is 2
value - value % 1
Ceiling Number
1.Ceiling is 1
2.4.Ceiling is 3
value - (value + 1 - Epsilon) % 1
Round Number
2.4.Round is 2
2.6.Round is 3
3.5.Round is 4
value - (value + 0.5) % 1
Absolute Number
-1.Absolute is 1
1.Absolute is 1
value < 0 then 0 - value else value
IsNearlyEqual(other, difference = Epsilon) Boolean
2.30000001.IsNearlyEqual(2.3)
(value - other).Absolute < difference
Clamp(minimum = 0, maximum = 1) Number
1.7.Clamp(0.5, 1.5) is 1.5
0.3.Clamp is 0.3
-0.8.Clamp(-0.5, 0.5) is -0.5
value > maximum then maximum else value < minimum then minimum else value
Lerp(other, percentage Number) Number
1.Lerp(3, 0) is 1
0.Lerp(1, 0.2) is 0.2
-1.Lerp(1, 0.5) is 0
-4.Lerp(-1, 1.5) is 0.5
value * (1 - percentage) + other * percentage
and(other) Number
2 and 6 is 6
1 and 8 is 9
9 and 1 is 9
value
or(other) Number
2 or 3 is 3
16 or 8 is 16
value
xor(other) Number
1 xor 1 is 0
3 xor 2 is 1
value
is(other) Boolean
1 is 1
2 is not 3
value is other
+(other) Number
3 + 4 is 7
value + other
-(other) Number
-1 * 5 is -5
3 - 2 is 1
value - other
/(other) Number
0 / 50 is 0
1 / 20 is 0.05
value / other
*(other) Number
3 * 4 is 12
value * other
%(other) Number
100 % 10 is 1
value % other
^(other) Number
2 ^ 2 is 4
value ^ other
>(other) Boolean
0 > 0 is false
3 > 1
value > other
>=(other) Boolean
0 >= 0
value >= other
<(other) Boolean
0 < 0 is false
1 < 3
value < other
<=(other) Boolean
0 <= 0
value <= other
Increment(amount = 1) Mutable(Number)
Mutable(5).Increment.Decrement.Increment is 6
Mutable(4).Increment(4) is 8
value = value + amount
Decrement(amount = 1) Mutable(Number)
Mutable(3).Decrement is 2
Mutable(-2).Decrement(-7) is -9
value = value - amount
SquareRoot Number
4.SquareRoot is 2
9.SquareRoot is 3
value ^ 0.5