in reply to Re^2: Portability of floor(log(N))
in thread Portability of floor(log(N))
This indicates that when the floating point precision is 64 bits, the correct floor() result is -12.use strict; use warnings; use Math::MPFR qw(:mpfr); # Set precision for extended # precision 'long double' Rmpfr_set_default_prec(64); my $num = Math::MPFR->new('1e-33'); my $thou = Math::MPFR->new('1000'); # Convert $num & $thou to their # respective log() Rmpfr_log($num, $num, MPFR_RNDN); Rmpfr_log($thou, $thou, MPFR_RNDN); print $num / $thou; # prints -1.10000000000000000009e1
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^4: Portability of floor(log(N))
by syphilis (Archbishop) on Mar 14, 2018 at 02:42 UTC | |
by toolic (Bishop) on Mar 14, 2018 at 17:31 UTC | |
by pryrt (Abbot) on Mar 14, 2018 at 18:22 UTC |