News:

Masm32 SDK description, downloads and other helpful links
Message to All Guests
NB: Posting URL's See here: Posted URL Change

Main Menu

128-bit integer arithmetic using FP

Started by jack, March 27, 2025, 12:29:22 AM

Previous topic - Next topic

jack

un-optimized times
n = 340282366920938463447387429234553266722
d = 18446744073709551615
product = 45370982256125128475310893311622766046
sum of product = 113427455641665582386530236262442737152
assembler version
elapsed time seconds  0.642031399998814

n = 340282366920938463447387429234553266722
d = 18446744073709551615
product = 45370982256125128475310893311622766046
sum of product = 113427455641665582386530236262442737152
high level version
elapsed time seconds  2.85223180000321

jack

Quote from: zedd151 on March 29, 2025, 02:58:19 AMBut wait, something is amiss.
'sum of product = 226854911283331164773060472524885474304' - for the high level version in my test?

and 'sum of product = 113427455641665582386530236262442737152' - for the high level version in your test.
I had forgotten to zero out the sum for the second test, so it just kept adding, it's fixed now if you want to download the binary

zedd151

Quote from: jack on March 29, 2025, 03:06:22 AMI had forgotten to zero out the sum for the second test, so it just kept adding, it's fixed now if you want to download the binary
:biggrin:

Intel(R) Core(TM) i7-7700 CPU @ 3.60GHz  3.60 GHz

multiply n times d 100000000 times in a loop
a sum of the product is kept and printed out
in order to prevent gcc from eliminating the loop
and thereby making the timing meaningless

n = 340282366920938463447387429234553266722
d = 18446744073709551615
product = 45370982256125128475310893311622766046
sum of product = 113427455641665582386530236262442737152
assembler version
elapsed time seconds  0.338004100020044

n = 340282366920938463447387429234553266722
d = 18446744073709551615
product = 45370982256125128475310893311622766046
sum of product = 113427455641665582386530236262442737152
high level version
elapsed time seconds  0.0723988000536337

press return to end

perfect.  :azn:
Side note: A humongous difference between unoptimised C version and optimized C version. Biterider might have to tweak his code (or you may need to tweak your conversion) to be a contender.  :tongue:

These huge numbers remind me of my experiments with my 'ascii_adder' routine. It added two humongous ascii decimal strings of any length together, outputting an ascii string on return. May be good for working with the U.S. national debt?  :biggrin:
¯\_(ツ)_/¯   :azn:

'As we don't do "requests", show us your code first.'  -  hutch—