Infinite-precision arithmetic
xbury.cs at clearstream.com
xbury.cs at clearstream.com
Tue May 24 06:35:26 EDT 2005
If you want to tackle multiplications, you should do it via bases...
10 and 2 being the easiest but not the most efficient.
Knowing the laws of power series and logs will be of great help
as they can tell you what digit goes where... But Rev can't handle
the sums so you need an array (or items) to do the digit/symbol
segmentation per polinomial level.
So in the end, it's like doing the math with paper and pencil ;)
cheers
Xav
On 24.05.2005 11:55:25 use-revolution-bounces wrote:
>sez xbury.cs at clearstream.com:
>>Very nice!
>Thanks!
>
>>That's the easy part though ;)
>[nods] Don't I know it!
>
>>Divisions is where it gets harder...
>And square roots... and powers... and DIV and MOD... and...
>I've already come up with an infinite-precision algorithm for
>multiplication which looks promising; I haven't coded it up yet, however,
so I
>am not
>entirely certain how well it will work out "in real life". In pseudocode:
>
>InfPreMult N1, N2
>put 0 into Rezult
>Put N1 into Fred
>Repeat until N2 = 0
>If N1 is odd then add Adder to Rezult
>Add Fred to Fred
>put N1 div 2 into N1
>end repeat
>End of algorithm
>
>Naturally, there's also the option of splitting N1 and N2 up into
>7-character chunks, doing all the multiplies for the relevant
chunk-pairs, and
>combining the results of said multiplies. That looks like it'd be a pain
to
>code, so
>I am going to try the other algorithm first. Depending on how fast it is,
I
>may or may not want to give "7-char chunks" a try as well.
>
>>...and using arrays may be much more efficient than using strings or
>numbers...
>>But items could work well too but wouldn't it be slower?
>I've never touched arrays before. I shall have to see if arrays make a
>difference, speed-wise. Every millisecond -- heck, every *micro*second --
counts
>in this sort of thing.
>_______________________________________________
>use-revolution mailing list
>use-revolution at lists.runrev.com
>http://lists.runrev.com/mailman/listinfo/use-revolution
-----------------------------------------
Visit us at http://www.clearstream.com
IMPORTANT MESSAGE Internet communications are not secure and therefore
Clearstream International does not accept legal responsibility for the
contents of this message. The information contained in this e-mail is
confidential and may be legally privileged. It is intended solely for the
addressee. If you are not the intended recipient, any disclosure, copying,
distribution or any action taken or omitted to be taken in reliance on it,
is prohibited and may be unlawful. Any views expressed in this e-mail are
those of the individual sender, except where the sender specifically states
them to be the views of Clearstream International or of any of its
affiliates or subsidiaries. END OF DISCLAIMER
More information about the use-livecode
mailing list