Reputation: 447
I get a point in the 2-D plane (x,y) as input. Now I have to check which quadrant it is in, do some Reflections about X-axis and Y-axis and check again which quadrant it is in repeatedly for a large number of times.
I have two approaches but not sure which is better
Upvotes: 0
Views: 198
Reputation: 258648
Neither, just compare your coordinates to 0
.
If you store them as boolean, besides losing information, you'll probably get some overhead because of the conversion.
If you check the first bit, it will be less readable.
The compiler will optimize these calls on its own, doubt you'll gain anything from a different approach.
Upvotes: 2