Dear Monks,
I'm not sure how I can understand the output I'm getting from the sample program below. Maybe (probably) something quite simple that I'm missing..
I need to calculate square roots with more than the standard precision so I'm using
use bignum. This works fine unless it is in a loop. Anybody care to explain?
use strict;
use warnings;
use Data::Dumper;
use bignum(a=>200);
my $s = sqrt(2);;
print Dumper(\$s);
for my $num (2..2) {
$s = sqrt($num);
print Dumper(\$s);
}
The output is:
$VAR1 = \bless( {
'_es' => '-',
'_m' => [
605715,
1152782,
9995050,
5927557,
5927505,
1322266,
9358314,
1497099,
1264412,
8507372,
4836055,
9702492,
2309122,
5013846,
4157273,
5343276,
8850387,
6210703,
7324784,
9737990,
7317667,
3769480,
9671875,
9807856,
7242096,
8801688,
7309504,
2135623,
1414
],
'_a' => 200,
'_e' => [
199
],
'sign' => '+'
}, 'Math::BigFloat' );
$VAR1 = \'1.4142135623731';
It looks as if the blessing of
$s is lost in the loop, but I don't understand why.
si_lence (confused)
Update: Thanks everybody for pointing out the reason and the suggestions. I did read the documentation, but obviously glossed over the important part.