Author: Gerd Isenberg
Date: 10:43:03 10/31/03
Go up one level in this thread
On October 31, 2003 at 09:04:41, Charles Roberson wrote: > > I have a list of numbers that I wanted to normalize to the range of 0-100. > The numbers are integers so the obvious thought is > find largest > foreach number > number = number*100/largest > > However, division is slow. So, I dropped the range to 0-64 and > came up with the following: > find largest > n = 7; > if largest > 64 > n = highorder bit position (largest) + 1; > foreach number > number = number>>n > > In some cases the range will be 0-32 but that is ok. > Seems this should be fast and I haven't thought of anything faster. I guess unsigned is fine here too. What is the largest possible value at all? If it is a real hotspot, you may consider MMX (or SSE2), processing 4(8)*16 or 2(4)*32-bit (unsigned) integers simultaneously. With MSVC you have intrinsic datatypes as well as functions for that. 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.