Logo 
Search:

Java Answers

Ask Question   UnAnswered
Home » Forum » Java       RSS Feeds
  Question Asked By: Violet Nelson   on Feb 25 In Java Category.

  
Question Answered By: Sheryl Morgan   on Feb 25

Keep in mind that any odd number  can be broken up into an even
number+1. Also remember how numbers are stored in binary (a sum of
different powers of 2). Since an odd  number always has the number 1 in
its sum, you can check the bit for that value by doing a bitwise and.
If the bit is set, then the number's odd.

Conditional:
Do you mean the ternary operator? --> (cond) ? doIfTrue: doIfFalse

The only way I see of using this is (cond)?true:false;, where cond is
any check for an odd number.

Share: 

 

This Question has 1 more answer(s). View Complete Question Thread

 
Didn't find what you were looking for? Find more on Beginers Problem Or get search suggestion and latest updates.


Tagged: