from the docs:
CAVEATS Do not try to be clever to insert some operations in between switching + libraries: ... This will create objects with numbers stored in two different backend +libraries, and VERY BAD THINGS will happen when you use these togethe +r:
so maybe better use ->bfloor() instead of int !?! :)
¹) but curiosity killed my cat: ;-)
code
output#!/usr/bin/perl -w use strict; use Math::BigFloat ':constant'; use Data::Dump qw/pp/; print "150 / 0.75 == ", 150 / 0.75, "\n"; print "150.5->bfloor() == ", 150.5->bfloor() / 0.75, "\n"; print "150 / 3.75 == ", 150 / 3.75, "\n"; print "150.5->bfloor() / 3.75 == ", 150.5->bfloor() / 3.75, "\n"; my $float=3.1415926; pp $float; pp $float->bfloor(); pp int($float);
150 / 0.75 == 200 150.5->bfloor() == 200 150 / 3.75 == 40 150.5->bfloor() / 3.75 == 40 bless({ _e => [7], _es => "-", _m => [1415926, 3], sign => "+" }, "Mat +h::BigFloat") bless({ _e => [0], _es => "+", _m => [3], sign => "+" }, "Math::BigFlo +at") bless({ sign => "+", value => [3] }, "Math::BigInt")
Please note that int produces an object of type Math::BigInt which was never used !!!
Not sure if Math::BigFloat should better try to overwrite CORE::int() differently...
Cheers Rolf
( addicted to the Perl Programming Language)
¹) nope it's overwritten, see update and following discussion.
In reply to Re: Unexpected inf and NaN (+ example)
by LanX
in thread Unexpected inf and NaN
by Anonymous Monk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |