News:

MASM32 SDK Description, downloads and other helpful links
MASM32.com New Forum Link
masmforum WebSite

Magic numbers (divide by multiplying)

Started by Jimg, June 29, 2009, 04:02:15 PM

Previous topic - Next topic

Jimg

I had a link somewhere to a site that showed how to compute magic numbers but I can't seem to find it.
I want to compute some 64 bit multipliers, e.g. for 1.0e-20, but am having a senior moment.
Anyone have the link to the site that explains this?

dedndave

it is easy to calculate
just look for Raymonds posts - lol
give me a minute i will see if i can find it...

look at Raymonds post in this thread...
http://www.masm32.com/board/index.php?topic=5821.0

also, i found a pdf that has some ideas that extend the method...
http://www.masm32.com/board/index.php?topic=11741.0

EDIT
notice that Raymond increments the magic number

Jimg

Hi Dave-

Thanks, but not exactly what I was looking for.
I know how to do a simple inverse (although, not in 64-bit yet).
I just seem to remember a site that explained the optimum combo of multiply and shift.
I never thought getting old would be this much hassle mentally.

drizz

read about it in Agner Fogs optimization manual ( also look in AMD-optimization manual ).

or use qWord's utility:
http://www.masm32.com/board/index.php?topic=9937.msg72815#msg72815
The truth cannot be learned ... it can only be recognized.

Jimg