Write an efficient function to Compute the sign of an integer without branching (if statements etc..)
Try this:
sign=((sqrt(number*number))/(-1*number))+44;
Regards,
Well, estentially the conditional operater is just a convienent way to write and if-else
The algorithm should not have ANY kind of branching statements
Is this what you expecting?:
sign = (0 < givenNumber)? '+' : '-' ;
Compute the sign of an integer without branching
Try this:
sign=((sqrt(number*number))/(-1*number))+44;
Regards,
Compute the sign of an integer without branching
Well, estentially the conditional operater is just a convienent way to write and if-else
The algorithm should not have ANY kind of branching statements
Compute the sign of an integer without branching
Is this what you expecting?:
sign = (0 < givenNumber)? '+' : '-' ;