1 |
# spec/oil-expr-arith |
2 |
|
3 |
#### Addition, with conversion from string |
4 |
|
5 |
var i = 1 + 2 |
6 |
|
7 |
var j = ' 2.5 ' + ' 3' |
8 |
|
9 |
var k = ' 5.0 ' - ' 2.5 ' |
10 |
|
11 |
var n = ' 2 ' * 3 * ' 4 ' |
12 |
|
13 |
write -- $i $j $k $n |
14 |
|
15 |
## STDOUT: |
16 |
3 |
17 |
5.5 |
18 |
2.5 |
19 |
24 |
20 |
## END |
21 |
|
22 |
|
23 |
#### Floating Point Division with / |
24 |
|
25 |
var i = '1.0' / '0.05' |
26 |
|
27 |
echo $i |
28 |
|
29 |
## STDOUT: |
30 |
20.0 |
31 |
## END |
32 |
|
33 |
|
34 |
#### Operations That Convert to Integer: // % ** |
35 |
|
36 |
var m = ' 5 ' // 2 |
37 |
|
38 |
var n = ' 5 ' % 2 |
39 |
|
40 |
var p = ' 5 ' ** 2 |
41 |
|
42 |
write -- $m $n $p |
43 |
|
44 |
## STDOUT: |
45 |
2 |
46 |
1 |
47 |
25 |
48 |
## END |