$a = -1.; "$a";
print $a + 1 == 0 ? "ok 19\n" : "not ok 19 #" . $a + 1 . "\n";
+sub ok { # Can't assume too much of floating point numbers.
+ my ($a, $b, $c);
+ abs($a - $b) <= $c;
+}
+
$a = 0.1; "$a";
-print $a + 1 == 1.1 ? "ok 20\n" : "not ok 20 #" . $a + 1 . "\n";
+print ok($a + 1, 1.1, 0.05) ? "ok 20\n" : "not ok 20 #" . $a + 1 . "\n";
$a = -0.1; "$a";
-print $a + 1 == 0.9 ? "ok 21\n" : "not ok 21 #" . $a + 1 . "\n";
+print ok($a + 1, 0.9, 0.05) ? "ok 21\n" : "not ok 21 #" . $a + 1 . "\n";
$a = .1; "$a";
-print $a + 1 == 1.1 ? "ok 22\n" : "not ok 22 #" . $a + 1 . "\n";
+print ok($a + 1, 1.1, 0.005) ? "ok 22\n" : "not ok 22 #" . $a + 1 . "\n";
$a = -.1; "$a";
-print $a + 1 == 0.9 ? "ok 23\n" : "not ok 23 #" . $a + 1 . "\n";
+print ok($a + 1, 0.9, 0.05) ? "ok 23\n" : "not ok 23 #" . $a + 1 . "\n";
$a = 10.01; "$a";
-print $a + 1 == 11.01 ? "ok 24\n" : "not ok 24 #" . $a + 1 . "\n";
+print ok($a + 1, 11.01, 0.005) ? "ok 24\n" : "not ok 24 #" . $a + 1 . "\n";
$a = 1e3; "$a";
print $a + 1 == 1001 ? "ok 25\n" : "not ok 25 #" . $a + 1 . "\n";