Skip to main content
gamedev.net
🔒 Locked

Performance Question

Started by level10boy Oct 22, 2001 at 5:41 PM 5 replies 300+ views
Original Post
level10boy
level10boy
Can anyone tell what is faster, bitwise comparisons or logical comparaisons. For example is, which of the following is faster? 1. int a = 5; int b = 5; if ( a && b ) cout << "equal"; 2. int a = 10; if ( a & 0x0000000A ) cout << "equal"; Thanks for any answers.
Marvin
Marvin
neither

seeing as at compile time it''ll get converted too..

if ( a & 0x0000000A )

why goto the hassle
level10boy
level10boy
Thanks for all your replies, and I''ll take it all into consideration.
Shannon Barber
Shannon Barber
Optimizations on this level save you at most a few CPU ticks (i.e. a few nanoseconds on today''s PCs), so it really doesn''t matter unless you perform the operation literally tens of million times per second.

Optimization in games today are about better scene graph management - things like BSP trees perform well no matter how slowly they''re implemented because they save orders of magnitude more time than they take to execute.
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
Oluseyi
Oluseyi
quote:
Original post by level10boy
Can anyone tell what is faster, bitwise comparisons or logical comparaisons. For example is, which of the following is faster?

As the Anonymous Poster mentioned, your first example isn't a bitwise comparison but a logical one (with a slightly different set of rules). Here's an even better example:

int a = 5;
int b = 2;
if(a && b)
cout << "equal" endl; // will execute

Guess why?

Edit: formatting.

Edited by - Oluseyi on October 23, 2001 2:54:23 AM

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.