Beefy Boxes and Bandwidth Generously Provided by pair Networks
Think about Loose Coupling
 
PerlMonks  

Re: significant digits in computations

by lhoward (Vicar)
on Jun 12, 2000 at 16:19 UTC ( [id://17695]=note: print w/replies, xml ) Need Help??


in reply to significant digits in computations

This is slightly off-topic since the original poster was asking about fixed-point arithmetic, and not really significant digits, but....

It would be cool to have a perl library that would automatically apply the scientific "number of significant digits" rules.

my $n1=new Number::Scientific(5500,3); #5500 w/ 3 significatn digits my $n2=new Number::Scientific(3.141592,7) # pi w/ 7 siginificant digit +s my $n3=$n1*$n2; my $n4=$n2/$n1; my $n5=$n1+$n2; print "$n3 $n4 $n5\n";
would output 17300 0.000571 5500. Unfortunately I don't think any such beast exists.

Replies are listed 'Best First'.
RE: Re: significant digits in computations
by chromatic (Archbishop) on Jun 12, 2000 at 19:23 UTC
    What about Math::BigFloat? It's in the standard distribution since about 5.002, I think. Or do you mean something to track Significant Digits and make the results of their calculations return only the sigdigs?
      What I am talking about is something that would track (and apply) significant digits internally. I could multiply a number with 2 significant digits by a number with 3 significant digits and when I went to display the results it would know that there were 2 significant digits and display apropriately without having to manually keep track of significant digits or decimal places myself.

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others learning in the Monastery: (3)
As of 2024-04-19 17:11 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found