Which is faster? ulong or double

Walter Bright newshound1 at digitalmars.com
Thu Sep 27 13:08:42 PDT 2007


Janice Caron wrote:
> ulong sounds the most logical, since the quantity will always be an
> integer, but (correct me if I'm wrong) ulongs are emulated in
> software, which is fine for add and subtract, but not so fine for
> divide; whereas doubles have direct hardware support, and so might
> actually end up being faster if there are lots of divides.

Ulong divides are emulated in software only if the divisor has any bits 
set in the high 32 bits. Otherwise, the DIV instruction is used. There 
are two DIV's if there are high bits set in the dividend.

BTW, ulong has more bits of *integral* precision than double or real.

As to which is faster, I suggest benchmarking it.



More information about the Digitalmars-d mailing list