Thanks. I got that corrected. Actually, in my code, $n wasnt a Math::BigFloat OBJECT.
On 4/25/07, Rob Dixon <[EMAIL PROTECTED]> wrote:
Somu wrote: > On 4/25/07, Tom Phoenix <[EMAIL PROTECTED]> wrote: >> >> On 4/24/07, Somu <[EMAIL PROTECTED]> wrote: >>> >>> I'm unable to compare numbers using the module. Actually i can only >>> use it to create numbers like 0 or inf or 1 or their negatives. But i >>> dont know how to use their methods. Bcoz the examples in the doc >>> aren't working. Can i get some simple examples? >> >> What are you doing that isn't working? "Because" if the documentation >> examples don't work for you, why should this work? >> >> #!/usr/bin/perl >> >> use strict; >> use warnings; >> >> use Math::BigFloat; >> >> my $$$$big = Math::BigFloat->new(200); >> my $$$$other = Math::BigFloat->new(100); >> >> if ($$$$big > $$$$other) { >> print "It seems that $$$$big is bigger than $$$$other. "; >> } else { >> print "Actually $$$$other is at least as large as $$$$big. "; >> } > > Actually the following isnt working: > > use Math::BigFloat; > $$n = 0; > if ($$n->is_zero()) {print 'you entered zero'} This isn't working because 0 is an integer, not a Math::BigFloat object. You can get Perl to represent all your /floating-point/ constants as Math::BigFloat objects by changing the use line to use Math::BigFloat ':constant'; which makes $$n = 0.0; if ($$n->is_zero) {print 'you entered zero'} work as you expected. HTH, Rob
-- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/