Compiler optimizations (I'm baffled)

Bruno Medeiros brunodomedeirosATgmail at SPAM.com
Wed May 3 11:11:14 PDT 2006


Walter Bright wrote:
> Craig Black wrote:
>>  This is
>> because integer division is essentially floating point division under the
>> hood.
> 
> Not exactly. What is true is that both kinds of division are based on 
> the same 'shift and subtract' method (the same algorithm taught in 3rd 
> grade for doing long division). If you're really interested in exactly 
> how integer and floating point division work, get the Digital Mars CD 
> which has complete source code to an IEEE 754 floating point emulator, 
> as well as code to do integer division for long's.
> 
> www.digitalmars.com/shop.html

I ran these tests and I got basicly the same results (the int division 
is slower). I am very intrigued and confused. Can you (or someone else) 
explain briefly why this is so?
One would think it would be the other way around (float being slower) or 
at least the same speed.

-- 
Bruno Medeiros - CS/E student
http://www.prowiki.org/wiki4d/wiki.cgi?BrunoMedeiros#D



More information about the Digitalmars-d mailing list