in reply to Re^3: Using big numbers correctly
in thread Using big numbers correctly
You get the correct output using "print" and "say" owing to operator overloading, and because $crt1 is a Math::BigFloat object.use warnings; use strict; use Math::BigFloat; use feature ':5.10'; my $x = Math::BigFloat->new('954846259588805228035541587771'); print $x->bdstr(), "\n"; print $x, "\n"; say $x; printf "%.0f\n", $x; printf "%.29e\n", 954846259588805228035541587771; __END__ Outputs: 954846259588805228035541587771 954846259588805228035541587771 954846259588805228035541587771 954846259588805282215996948480 9.54846259588805282215996948480e+29
use warnings; use strict; use Math::BigFloat; use feature ':5.10'; my $x = Math::BigFloat->new('954846259588805228035541587771'); print $x * 2, "\n"; print $x * 2.5, "\n"; print $x * Math::BigFloat->new('2.5'), "\n"; print $x * "2.5"; __END__ Outputs: 1909692519177610456071083175542 2387115648972013070088853969427.5 2387115648972013070088853969427.5 2387115648972013070088853969427.5
|
|---|