|Perl: the Markov chain saw|
Re: Math::FixedPrecision and bignum clashby thanos1983 (Parson)
|on Oct 08, 2014 at 12:58 UTC||Need Help??|
I did a bit of a research as McA did but on a different area. I came up with the following:
Then I went I start reading for bignum and I found this:
All operators (including basic math operations) are overloaded. Integer and floating-point constants are created as proper BigInts or BigFloats, respectively.
If you do use bignum;
at the top of your script, Math::BigFloat and Math::BigInt will be loaded and any constant number will be converted to an object (Math::BigFloat for floats like 3.1415 and Math::BigInt for integers like 1234).
If I understand correctly, your problem is that you want to have accuracy to the nth digit of your float, but at the same time you want to use the bignum module.
Update: I just thought that maybe you are interested in just getting the 2 digits after the dot of a float, without rounding. In that case the solution could be much more simpler by using substr. If this is what you are looking for you can simply do that:
Update 2: wrong output, correcting output. I was experimenting and accidentally I posted before the experimentation.
Alternatively if my assumption is correct, sample of working code with the output:
Seeking for Perl wisdom...on the process of learning...not there...yet!