Beefy Boxes and Bandwidth Generously Provided by pair Networks
No such thing as a small change
 
PerlMonks  

Re^4: Help me make a test case for Math::BigFloat

by fizbin (Chaplain)
on Mar 06, 2006 at 21:34 UTC ( #534763=note: print w/replies, xml ) Need Help??


in reply to Re^3: Help me make a test case for Math::BigFloat
in thread Help me make a test case for Math::BigFloat

Good idea - thanks.

I eventually did find a way to simplify the math, and here's the test case I sent off:

#!perl use strict; use warnings; use Test::More tests => 4; use bignum; my $lnev = -7 / (10**17); my $ev=exp($lnev); is( sprintf('%0.5f',$ev) , '1.00000', '($ev) is approx. 1' ); is( sprintf('%0.5f',1-$ev) , '0.00000', '(1-$ev) is approx. 0' ); is( sprintf('%0.5f',1-"$ev") , '0.00000', '(1-"$ev") is approx. 0' ); cmp_ok( $ev, '!=', 0, '$ev should not equal 0');
Note that by futzing with the $lnev number, you can get this bug to disappear - for example, by changing the "7" to a "1".
--
@/=map{[/./g]}qw/.h_nJ Xapou cets krht ele_ r_ra/; map{y/X_/\n /;print}map{pop@$_}@/for@/

Replies are listed 'Best First'.
Re^5: Help me make a test case for Math::BigFloat
by xdg (Monsignor) on Mar 06, 2006 at 21:53 UTC
    Note that by futzing with the $lnev number, you can get this bug to disappear.

    I'd add that to the test case. I find it helpful to show both working and non-working variations. Easier to drill in on what's happening.

    -xdg

    Code written by xdg and posted on PerlMonks is public domain. It is provided as is with no warranties, express or implied, of any kind. Posted code may not have been tested. Use of posted code is at your own risk.

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others perusing the Monastery: (2)
As of 2022-08-18 02:23 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found

    Notices?