-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathNumber.strict
86 lines (86 loc) · 1.5 KB
/
Number.strict
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
has iterator
to Text
5 to Text is "5"
10.1 to Text is "10.1"
for digits
Character(value)
digits Numbers
1.digits is (1)
123.digits is (1, 2, 3)
constant nextPart = (number / 10).Floor
constant currentDigit = number % 10
nextDigit is 0 ? currentDigit else nextPart.digits + currentDigit
Floor Number
1.Floor is 1
2.4.Floor is 2
value - value % 1
is(other) Boolean
"Hey" is "Hey" is true
"Hi" is "Hey" is false
value is other
- Number
-1 is not 1
-value
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
is not(other) Boolean
1 is not 3
2 is not 3
value is not 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 is true
value > other
>=(other) Boolean
0 >= 0 is true
value >= other
<(other) Boolean
0 < 0 is false
1 < 3 is true
value < other
<=(other) Boolean
0 <= 0 is true
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