in reply to Re^8: subtraction issue
in thread subtraction issue
So if I want to assign (from a string) the value held by that double to a 53-bit precision object I can just assign the string "1.3".use strict; use warnings; use Math::MPFR qw(:mpfr); my $prec_53 = Rmpfr_init2(53); my $prec_4000 = Rmpfr_init2(4000); my $d = 1.3; Rmpfr_set_d($prec_53, $d, MPFR_RNDN); # The 53 bits of $prec_53 are now set to: # 10100110011001100110011001100110011001100110011001101 Rmpfr_set_d($prec_4000, $d, MPFR_RNDN); # The first 53 bits are as for $prec_53 # The remaining 3947 bits are 0. # But we'll run a check: die "Things aint right" if $prec_53 != $prec_4000; print "$prec_53\n"; # prints 1.3 print "$prec_4000\n"; # prints 1.3000000000000000444089209850062616169452667236328125
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^10: subtraction issue
by BrowserUk (Patriarch) on Jan 29, 2017 at 00:58 UTC | |
by syphilis (Archbishop) on Jan 29, 2017 at 08:47 UTC |