Boost logo

Boost :

Subject: Re: [boost] How to find: best integer type for processor
From: Simonson, Lucanus J (lucanus.j.simonson_at_[hidden])
Date: 2008-10-30 13:16:01

On Thu, Oct 30, 2008 at 4:24 PM, Daryle Walker <darylew_at_[hidden]> wrote:
> Is there a macro and/or typedef that will tell me bit-length used for a
> processor and/or the best integer type for said processor? The "int" type
> is supposed to be that type, and it was in the 16- and 32-bit eras. (I
> learned C programming with the former in the... early 1990s!) However, the
> powers-that-be decided, for "backwards compatibility," to freeze "int" and
> "long" at 32 bits and use a new type, "long long," for 64 bits, which should
> be the optimized integer type for 64-bit processors. (If they kept to the
> plan, "int" would be 64 bits, "long" either 64 or 128, "short" up to 32, and
> the new type will be "short short" at 16.) I want to know the best type so,
> when I build multi-integer arrays for various purposes, I don't pick an
> element type that causes a slow down, whether to focus on a fraction of a
> register (if the chosen type is too small) to handle two registers at once
> (if the chosen type is too large).

Giovanni answered:
>A 32 bit integer *is* the best integer type for practically all 64 bit

I'm going to disagree with Giovanni here. For Daryle's purposes 64 bit is better on a 64 bit platform. I'd like to call your attention to the study performed by gmp

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