Author: Gerd Isenberg
Date: 00:42:07 09/27/03
Go up one level in this thread
On September 26, 2003 at 13:21:07, Koundinya Veluri wrote: >On September 26, 2003 at 10:29:09, Omid David Tabibi wrote: > >>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." >> > >That's true, converting from char to int can result in some overhead. But, I was >referring to char to char operations vs int to int operations; they should be >equally fast. Going back to the original topic, bool vs BOOL, I still prefer >bool because a conversion from bool to a larger type is not necessary, so bool >to bool operations and BOOL to BOOL operations should be equally fast. If it is >necessary to convert bool to int then I would consider that bad design. >Nevertheless, in that case BOOL would probably be more appropriate. > >Koundinya I use color (WHITE, BLACK) with int type, e.g. as array index. Is there a way in C++ to assign the color to a bool (bool isBlack(int color)) only by moving or using a partial byte register, e.g. color is in EAX, so the bool is already in AL? The compiler is not aware of the value range with only two values even with enum (int) type, which map perfectly to bool. Therefore the compiler will perform additional TEST and SETNZ instructions. If you use an int-BOOL and stay with probably ambiguous "TRUE"-values (all != 0) that is not necessary. Gerd
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.