I need high level of precision in my Perl script, so I'm using BigFloat. Everything works well within subroutines, but when I try to pass a BigFloat number from one sub to another it reverts to a regular float. Specifically, I don't think I have a problem putting big numbers into a subroutine, just making getting the output to be a big number. The numbers could be reverting to floats when I put them in the return array, or during the return process. Does anyone know how to: 1) Put BigFloat numbers into an array and 2) Pass BigFloat numbers between subroutines Thanks! Here's a snippet of the code:
#!/usr/bin/perl use strict; use Math::BigFloat; Math::BigFloat->accuracy(20); sub simulate_lifespan{ my $r = Math::BigFloat->new($_[0]); my $org_muv = Math::BigFloat->new($_[1]); my $org_muy = Math::BigFloat->new($_[2]); my $scaler = Math::BigFloat->new($_[3]); my $ext_death = Math::BigFloat->new($_[4]); my $lifetime_fitness = Math::BigFloat->new(0); my $log_lifetime_fitness = $lifetime_fitness->copy(); $log_lifetime_fitness ->blog(); my @return_array = ($time, $log_lifetime_fitness, $mean_v, $mean_y +); return \@return_array; }

In reply to Passing a BigFloat number through a subroutine by pgnelson307

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.