I am struggling with a number precision problem. Ideally, I would like to see every number that is calculated in my script (through division, multiplication, whatever...) automatically limited to 4 numbers to the right of the decimal point. According to this:-
http://perldoc.perl.org/Math/BigFloat.html
I should be able to manage that requirement through this command:-
Math::BigFloat->precision(-4);
...but I cannot get this to work at all. Has anyone tried to define a global setting like this before? If you didn't use Math::BigFloat, what was the alternative?
A simple example is below. Note that a *lot* of calculations are being exercised in the real script, so I would really like to get a global setting working.
Thanks,use Math::BigFloat; Math::BigFloat->precision(-4); for ($m = 1; $m <= 3; $m++) { for ($n = 1; $n <= 3; $n++) { $x = $m * $n * rand(3); print ("$x "); } print ("\n"); }
Fiddler42
In reply to Math::BigFloat question (precision) by fiddler42
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |