Computer Chess Club Archives


Search

Terms

Messages

Subject: Re: bool versus BOOL in C++

Author: Koundinya Veluri

Date: 07:23:19 09/26/03

Go up one level in this thread


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.

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.