in reply to Re^7: Math::BigFloat to native double?
in thread Math::BigFloat to native double?
They still don't add up to something near the original input value - but nor should they.0x1.921fb54442d18p+1 => 3.1415926535897931 0x1.1a62633145c07p-53 => 1.2246467991473532e-16
The sum of which is:0x1.921fb54442d18p+1 => 3.14159265358979311599796346854419 0x1.1a62633145c07p-53 => 1.2246467991473532071737640294584e-16
which outputs (when run with the "-l" switch):use Math::BigFloat;; $n = Math::BigFloat->new( '3.1415926535897932384626433832795' );; $d = 0 + $n->bstr;; printf "%.17f\n", $d;; printf "%a\n", $d;; $bfd = Math::BigFloat->new( sprintf "%.17f", $d );; print $bfd;; $n -= $bfd;; print $n;; printf "%a\n", $n;;
So the most significant double agrees with my ppc box, but the value of the least significant double differs.3.14159265358979310 0x1.921fb54442d18p+1 3.1415926535897931 0.0000000000000001384626433832795 0x1.3f45eb146ba31p-53
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^9: Math::BigFloat to native double?
by BrowserUk (Patriarch) on Jul 13, 2015 at 15:44 UTC | |
by syphilis (Archbishop) on Jul 14, 2015 at 03:45 UTC | |
by BrowserUk (Patriarch) on Jul 14, 2015 at 05:11 UTC | |
by syphilis (Archbishop) on Jul 14, 2015 at 13:14 UTC | |
by syphilis (Archbishop) on Jul 15, 2015 at 14:58 UTC | |
|