Boost logo

Boost :

From: John Max Skaller (skaller_at_[hidden])
Date: 2001-07-04 15:37:27

Beman Dawes wrote:
> At 03:10 PM 7/3/2001, helmut.zeisel_at_[hidden] wrote:
> >But how do you portable specify the fastest word size?
> >The answer might be different for a 16bit, 32bit, or a 64bit
> >platform offering a long long type.
> Sounds like cstdint.hpp needs:
> intfast_t
> uintfast_t

I think we should use:


We don't want the 'fastest' type here. We want the biggest.

The reason is: fastest means 'fasted to do calculations
with small operands'. We're not interest in that at all.
ALL multiple precision sub-operations must be considered to

If only we were certain to have uint32_t and uint64_t, we would
probably use uint32_t for the word size because then
multiplication can be done like

        uint64_t p = (uint64_t)a * (uint64_t)b;
        uint32_t low = p & 0xFFFFFFFF;
        uint32_t hi = p >> 32;

[ignoring carry]. This is the only way to do it,
so if we only have uintmax_t, there is no choice
but to write:

        uintmax_t alo = a & LOWORD;
        unitmax_t blo = b & LOWROD;
        unitmax_t ahi = a >> HALF_BITS;
        unitmax_t bhi = b >> HALF_BITS;

and now do a two 'digit' long multiply,
to get a four halfword result. This is slower
than the computation using half max word size,
due to shifting and masking, register spills,

        However, the fastest way can only be
done in machine code:

        MUL A,B // result in A:B register pair

John (Max) Skaller, mailto:skaller_at_[hidden] 
10/1 Toxteth Rd Glebe NSW 2037 Australia voice: 61-2-9660-0850
New generation programming language Felix
Literate Programming tool Interscript

Boost list run by bdawes at, gregod at, cpdaniel at, john at