Commit | Line | Data |
4d0ed6f7 |
1 | use integer; |
2 | |
3 | use Test::More tests => 11; |
4 | use Config; |
5 | |
6 | my $x = 4.5; |
7 | my $y = 5.6; |
8 | my $z; |
9 | |
10 | $z = $x + $y; |
11 | is($z, 9, "plus"); |
12 | |
13 | $z = $x - $y; |
14 | is($z, -1, "minus"); |
15 | |
16 | $z = $x * $y; |
17 | is($z, 20, "times"); |
18 | |
19 | $z = $x / $y; |
20 | is($z, 0, "divide"); |
21 | |
22 | $z = $x / $y; |
23 | is($z, 0, "modulo"); |
24 | |
25 | is($x, 4.5, "scalar still floating point"); |
26 | |
27 | isnt(sqrt($x), 2, "functions still floating point"); |
28 | |
29 | isnt($x ** .5, 2, "power still floating point"); |
30 | |
31 | is(++$x, 5.5, "++ still floating point"); |
32 | |
33 | SKIP: { |
34 | my $ivsize = $Config{ivsize}; |
35 | skip "ivsize == $ivsize", 2 unless $ivsize == 4 || $ivsize == 8; |
36 | |
37 | if ($ivsize == 4) { |
38 | $z = 2**31 - 1; |
39 | is($z + 1, -2147483648, "left shift"); |
40 | } elsif ($ivsize == 8) { |
41 | $z = 2**63 - 1; |
42 | is($z + 1, -9223372036854775808, "left shift"); |
43 | } |
44 | } |
45 | |
05f18d1e |
46 | is(~0, -1, "signed instead of unsigned"); |