in reply to Re: Math::BigFloat bnok() question
in thread Math::BigFloat bnok() question

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.

Replies are listed 'Best First'.
Re^3: Math::BigFloat bnok() question
by syphilis (Archbishop) on Aug 28, 2015 at 02:55 UTC
    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.

Re^3: Math::BigFloat bnok() question
by u65 (Chaplain) on Aug 28, 2015 at 02:44 UTC

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