27 lines
357 B
Perl
Executable File
27 lines
357 B
Perl
Executable File
#!/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;
|