Beefy Boxes and Bandwidth Generously Provided by pair Networks
more useful options
 
PerlMonks  

Re: Math::BigFloat bnok() question

by toolic (Bishop)
on Aug 27, 2015 at 19:40 UTC ( [id://1140246]=note: print w/replies, xml ) Need Help??


in reply to Math::BigFloat bnok() question

I will post the files that this code uses if necessary
It would be better to make your code independent of external files. Reduce your code to a small example that anyone can run to reproduce your error. What version of perl are you using?

Tip #2 from the Basic debugging checklist: print

print "$x\n"; print "$y\n";

Replies are listed 'Best First'.
Re^2: Math::BigFloat bnok() question
by azheid (Sexton) on Aug 27, 2015 at 19:46 UTC

    I am using perl 5.10.0. I was hoping the mistake was simple and easy for learned monks to figure out. I will try to make a simple example code.

      I will try to make a simple example code

      Here is a simple demo:
      use strict; use warnings; use Math::BigFloat; my $n = Math::BigFloat->new(7); my $k = 5; print $n->bnok($k), "\n"; # prints "21". my $n2 = 7; print $n2->bnok($k); # line 10
      It outputs:
      21 Can't call method "bnok" without a package or object reference at bnok +.pl line 10.
      No problem with the first bnok call, but the second fails because $n2 is not a Math::BigFloat object - and this supports the assertions already made by others in this thread.
      Apparently, $k doesn't need to be a Math::BigFloat object (though I think you'll find it can be).

      Cheers,
      Rob

        Thanks for your help, this solves my question. I figured out a way around the issue by finding a stand alone subroutine for the calculation and using bignum. The perl gods found a way to idiot proof these large number calculations, and to them I am thankful. Hopefully, another person will find either solution helpful.

      Unless I'm blind, I don't see you using use strict;use warnings; which may provide more enlightenment.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://1140246]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others chilling in the Monastery: (6)
As of 2024-03-28 11:50 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found