Boost Users :
Subject: Re: [Boost-users] How to find: best integer type for processor
From: Emil Dotchevski (emil_at_[hidden])
Date: 2008-10-30 18:45:28
On Thu, Oct 30, 2008 at 12:15 PM, Rodrigo Madera
>> IMO, on a 64-bit CPU int should be 64 bits, and long should be 128
> I agree that such a type should be available. Maybe not all ints directly, but have a word_t for that purpose.
> People may argue that "it's not needed" or redundant or whatever, but having the register width as a type could be really useful sometimes.
As the original message said, int is supposed to be the type that
matches the CPU register size.
The semantics of the C/C++ expressions have been carefully designed
for that purpose of int. For example, adding 2 shorts in C/C++
produces an int (not a short), because a typical CPU works most
efficiently with full registers (in fact it may not even have "half
With int being 32-bit on a 64-bit CPU, a C compiler is forced to
generate code that works with half registers, which would have been
inefficient had most 64-bit CPUs not been designed with this in mind.
Reverge Studios, Inc.
Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net