quote:Original post by cowsarenotevilNo; because dividing a number by two will return an integer if it''s divisible by two, and a rational if it''s not.
Yes, becuause dividing a number by two will return TRUE if it''s divisible by two, and FALSE if not. Oh wait, it doesn''t, so it''s not.
How to determine if one number is a power of another?
please...don''t start an argument on even and odd numbers, which is ultimately what the problem was about. modulo is our friend.
quote:Original post by Cedricquote:Original post by cowsarenotevilNo; because dividing a number by two will return an integer if it''s divisible by two, and a rational if it''s not.
Yes, becuause dividing a number by two will return TRUE if it''s divisible by two, and FALSE if not. Oh wait, it doesn''t, so it''s not.
Which isn''t easy to check on a computer due to floating point inaccuracies. You''ll need to check against some epsilon and so forth. Modulo math is the way to go.
quote:Original post by YoshiNquote:Original post by Cedricquote:Original post by cowsarenotevilNo; because dividing a number by two will return an integer if it''s divisible by two, and a rational if it''s not.
Yes, becuause dividing a number by two will return TRUE if it''s divisible by two, and FALSE if not. Oh wait, it doesn''t, so it''s not.
Which isn''t easy to check on a computer due to floating point inaccuracies. You''ll need to check against some epsilon and so forth. Modulo math is the way to go.
int n = blah;
if(n/2*2 == n) cout<<"yay!";
I''m closing the thread because it has nothing to do with game development and the original poster now has the answer he requested.
Graham Rhodes
Senior Scientist
Applied Research Associates, Inc.
Graham Rhodes
Senior Scientist
Applied Research Associates, Inc.
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement