blob: db7b35264e5783ddc4541e1f8d500dee648e8c14 (
plain)
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
|
# Tests for decimal numbers
func square(n:Dec -> Dec)
return n * n
func main()
>> one_third := $1/$3
= $0.333333333333333333333333333333
>> two_thirds := $2/$3
= $0.666666666666666666666666666667
>> one_third + two_thirds == $1
= yes
>> square(5) # Promotion
= $25
>> square(Dec(1.5))
= $2.25
# Round-to-even:
>> $1.5.round()
= $2
>> $2.5.round()
= $2
>> $2 + $3
= $5
>> $2 - $3
= -$1
>> $2 * $3
= $6
>> $3 ^ $2
= $9
>> $10.1 mod 3
>> $1.1
>> $10 mod1 5
>> $5
>> $1 + 2
= $3
>> $1 + Int64(2)
= $3
|