|
Boost : |
Subject: Re: [boost] How to find: best integer type for processor
From: Giovanni Piero Deretta (gpderetta_at_[hidden])
Date: 2008-10-30 13:23:22
On Thu, Oct 30, 2008 at 6:16 PM, Simonson, Lucanus J
<lucanus.j.simonson_at_[hidden]> wrote:
> 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
>>processor.
>
> 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
>
Well, mine was an answer to the general question 'why int is not 64
bits on 64 bit platforms'. Of course an application may have its
specific needs.
-- gpd
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk