script to compute ulp+ and ulp-

This commit is contained in:
hjp 2009-10-01 17:29:22 +00:00
parent db8cc1f569
commit 9ad679573c
1 changed files with 26 additions and 0 deletions

26
ieeefloat/ulp Executable file
View File

@ -0,0 +1,26 @@
#!/usr/bin/perl
use warnings;
use strict;
my $x = $ARGV[0] + 0;
my $d = 1;
while ($x + $d == $x) {
$d *= 2;
}
while ($x + $d/2 != $x) {
$d /= 2;
}
printf "ulp+ = %.17e %.17e %.17e\n", $d, $x, $x + $d;
$d = 1;
while ($x - $d == $x) {
$d *= 2;
}
while ($x - $d/2 != $x) {
$d /= 2;
}
printf "ulp- = %.17e %.17e %.17e\n", $d, $x, $x - $d;