Beefy Boxes and Bandwidth Generously Provided by pair Networks
Your skill will accomplish
what the force of many cannot
 
PerlMonks  

Re: Fraction Cancelation

by BillKSmith (Monsignor)
on Feb 24, 2016 at 18:05 UTC ( [id://1156045]=note: print w/replies, xml ) Need Help??


in reply to Fraction Cancelation

I would not rule out the possibility that straight forward floating point arithmetic is more "efficient" than any cancelation algorithm. Loss of precision could be a problem for large numbers and/or arrays. Alternating the multiplies and divides could help.
Bill

Replies are listed 'Best First'.
Re^2: Fraction Cancelation
by LanX (Saint) on Feb 24, 2016 at 19:11 UTC
    Good point.

    Sorting and alternating the arrays to keep the temporary product near 1 should help minimizing the error.

    Cheers Rolf
    (addicted to the Perl Programming Language and ☆☆☆☆ :)
    Je suis Charlie!

Re^2: Fraction Cancelation
by Laurent_R (Canon) on Feb 24, 2016 at 21:53 UTC
    It really depends on the purpose of the whole thing. For some uses, floating point arithmetic is probably just good enough, and may very well be the most efficient solution; for example, it would probably be just good enough is the final aim is to compute probabilities.

    For some others purposes, you may need accurate integer arithmetic.

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others imbibing at the Monastery: (2)
As of 2024-04-20 01:03 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found