Author: Russell Reagan
Date: 21:14:29 07/07/03
Go up one level in this thread
I looked in a book I have titled "Hacker's Delight", and it had a few good
absolute value functions in it. hd1 and hd2 did very well.
int hd1_abs (int x) {
int y = x >> 31;
return (x ^ y) - y;
}
int hd2_abs (int x) {
int y = x >> 31;
return (x + y) ^ y;
}
int hd3_abs (int x) {
int y = x >> 31;
return x - ((x + x) & y);
}
int hd4_abs (int x) {
int y = x >> 31;
return x - ((x << 1) & y);
}
int hd5_abs (int x) {
return ((x >> 30) | 1) * x;
}
| best | average
| time | time
nothing 4238830751 | 0.981 | 0.991
hd2_abs() 1977337213 | 1.201 | 1.2072 <--
abs() 1977337213 | 1.202 | 1.210
hd1_abs() 1977337213 | 1.202 | 1.208 <--
omid_abs() 1977337213 | 1.202 | 1.210
cdq_abs() 1977337213 | 1.252 | 1.252
cmovl_abs() 1977337213 | 1.252 | 1.258
cmovs_abs() 1977337213 | 1.252 | 1.258
hd3_abs() 1977337213 | 1.301 | 1.3078
hd4_abs() 1977337213 | 1.302 | 1.312
sbb_abs() 1977337213 | 1.302 | 1.310
hd5_abs() 1977337213 | 1.412 | 1.414
sar_abs() 1977337213 | 1.502 | 1.51
simple_abs() 1977337213 | 1.922 | 1.926
fish_abs() 1977337213 | 2.343 | 2.343
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.