Computer Chess Club Archives


Search

Terms

Messages

Subject: Re: bool versus BOOL in C++

Author: Omid David Tabibi

Date: 07:29:09 09/26/03

Go up one level in this thread


On September 26, 2003 at 10:23:19, Koundinya Veluri wrote:

>On September 26, 2003 at 09:15:31, Omid David Tabibi wrote:
>
>>But isn't a word sized variable preferable to a 1 byte variable for performance?
>>
>>The reason why int doesn't have a specific size is that on each system int was
>>meant to be the fastest type of variable, word sized. That's why using int is
>>better than char even for small numbers (except when having large arrays where
>>int would waste too much cache). For the same reason I think typedef int BOOL
>>would be better than bool when having only speed in mind.
>>
>>P.S. It seems that on 64 bit systems sizeof(int) will still be 4, not word
>>sized. Wouldn't an 8 byte int be faster than a 4 byte one on a 64 bit system?!
>>
>
>IMO a good compiler should do equally well for both since both int and char fit
>into one register. I don't see how int can perform better than char. I haven't
>noticed a difference in any of my programs, excluding the cases where cache is a
>factor, when char would perform better. Because of this I actually prefer using
>char instead of int where possible, and also bool instead of BOOL.


http://www.azillionmonkeys.com/qed/optimize.html

"The original reason int was put into the C language was so  that the fastest
data type on each platform remained abstracted away from the programmer himself.
 On modern 32 and 64 bit platforms,  small data types like chars and shorts
actually incur extra overhead  when converting to and from the default machine
word sized data type."


>
>Koundinya



This page took 0 seconds to execute

Last modified: Thu, 15 Apr 21 08:11:13 -0700

Current Computer Chess Club Forums at Talkchess. This site by Sean Mintz.