quote:Original post by fredizzimo
quote:Original post by Evil_Greven
fredizzimo,
Upon further testing of that segment with random numbers, it isn''t always detecting a collision correctly.
Of course it doesn''t I told you I was and still am very tired, but change 0x10000000 to 0x80000000 and it should(I hope).
And yes, as I told in my post, I don''t expect it to be faster. It should just serve as a proof that it''s not always worth optimizing tests away. But I''m still waiting for Magmai''s results
An optimizing compiler will perform sub-expression elimination for you, I guess it doesn''t hurt to give it hints.
However, this does not detect any collisions.
int jx=x-10;
int jy=y-10;
return jx-ix & ix-jx & jy-iy & iy-jy & 0x80000000;
Following your logic though, I came up with this:
segement5
return !!(0x8000000 & (x-ix-10 & y-iy-10 & -x+ix-10 & -y+iy-10));
2255038 hits out of 10,000,000 (22.55%) Avgerage StdDevSegment1: 1.814189 0.000286Segment2: 1.814146 0.000298Segment3: 1.791043 0.000413Segment4: 1.731903 0.000383 Segment5: 1.731680 0.000309361321 hits out of 10,000,000 (3.6%) Avgerage StdDevSegment1: 1.795704 0.000457Segment2: 1.795874 0.000400Segment3: 1.736898 0.000481Segment4: 1.731758 0.000392Segment5: 1.731592 0.000373
It appears to be ever-so-slightly faster, even though it''s doing much more math.
- The trade-off between price and quality does not exist in Japan. Rather, the idea that high quality brings on cost reduction is widely accepted.-- Tajima & Matsubara