Computer Chess Club Archives


Search

Terms

Messages

Subject: Re: optimization question

Author: Rémi Coulom

Date: 01:30:09 10/23/00

Go up one level in this thread


On October 23, 2000 at 01:09:02, Landon Rabern wrote:

>is it faster to cast to a char or to AND by 0xff, or to do they take the same
>number of clock cycles?
>
>Thanks,
>
>Landon W. Rabern

I would give this general advice :
- Use int everywhere you need speed (ie, do not cast to char), even if data
would fit in a short or a char.
- If you do not know which is faster, time a large loop for both and you will
know (it has dangers, but it will generally give you a good order of magnitude
of the difference). This kind of result is probably machine/compiler dependent.
A good compiler might generate exactly the same code for both if what you do is
really equivalent.

Remi



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.