Author: Russell Reagan
Date: 06:36:00 09/27/03
Go up one level in this thread
On September 27, 2003 at 08:22:47, Omid David Tabibi wrote: >Isn't it better to always use unsigned int instead of int, for example: > > for (unsigned int i; i < numner; i++) > >instead of > > for (int i; i < numner; i++) You could test it pretty easy. I have something in my program like this: typedef int Int32; typedef unsigned int UInt32; typedef Int32 Int; typedef Uint32 UInt; There are others for 16-bit and 8-bit data. The main advantage is that I can switch to a 64-bit platform by changing a line or two of code here (specifically, Int and UInt to be 64-bit types). I could add a FastInt type or something like that, which will just be the fastest available type when there is a choice between int and unsigned int. You could do two compiles and compare. Also worth checking out is this chart (http://www.tantalon.com/pete/cppopt/appendix.htm#AppendixB_RelativeCosts), although it is on a PIII. Note that the author says statistical error is +/- 0.1. It would be interesting to see how the author tested this. Also, is there a penalty for doing assignment between int and unsigned, and vice versa? It seems like some kind of conversion might be needed.
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.