[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [sc-users] Conversion decimal into fractional



Hi Philippe,

I did some additional methods for SimpleNumber and Integer that were
posted a few months ago. There's asFraction and a factorize method. The
algorithm is done by Farey fractions which gives very good aproximations.
Ex:

pi.asFraction
[ 22, 7 ]

pi.asFraction(1000)
[ 355, 113 ]

1000.factorize

List[ 2, 2, 2, 5, 5, 5 ]

1000.factorsList

List[ [ 2, 3 ], [ 5, 3 ] ]

I don't have much time now to explain the other methods (they're in the
list archives) but can do so later on or tomorrow if there is interest.

Cheers


JS


Attachment: numberExtras.sc
Description: Binary data