we can use masking of most significant bit of the xor of (a-x) and ( b-x)
to check if a<x<b
if [ ((a-x)^(b-x)) & 0x80000000 ]
then it's in range
else not in range
On Sat, Oct 27, 2012 at 11:17 PM, Vikram Pradhan <[email protected]>wrote:
> how about ...if( (a-x)^(b-x) < 0)
>
>
>
>
> On Sat, Oct 27, 2012 at 9:21 PM, Dave <[email protected]> wrote:
>
>> @Atul: Try x = 0, a = 1, b = 2, for which (x > a && x < b) is false, but
>> (x - a < b - x) is true.
>>
>> Dave
>>
>> On Saturday, October 27, 2012 5:43:17 AM UTC-5, ATul SIngh wrote:
>>
>>> Thnks but i figured it out
>>> as
>>> ( x >= a && x < b )
>>> or
>>> ( x >= a && x <= b )
>>>
>>> could be written as
>>> x -a < b - x for first case
>>> x -a <= b - x for sec one
>>>
>>> Second set is more optimised as it contains only one comparison and
>>> minus is much efficient than comparison operator.
>>>
>>>
>>>
>>> --
>>>
>>> *ATul Singh** Software Engineer**, Interra Systems*
>>> Mobile : +91-9971794013
>>> www.interrrasystems.com
>>> [image: Facebook] <http://www.facebook.com/atulsingh7890> [image:
>>> Twitter] <http://www.twitter.com/atulsng> [image:
>>> LinkedIn]<http://www.linkedin.com/in/atulsingh7890>
>>>
>>>
>>> --
>> You received this message because you are subscribed to the Google Groups
>> "Algorithm Geeks" group.
>> To view this discussion on the web visit
>> https://groups.google.com/d/msg/algogeeks/-/pyvTrbonkq4J.
>>
>> To post to this group, send email to [email protected].
>> To unsubscribe from this group, send email to
>> [email protected].
>> For more options, visit this group at
>> http://groups.google.com/group/algogeeks?hl=en.
>>
>
>
>
> --
> Vikram Pradhan | B.Tech| Computer Science & Engineering | NIT Jalandhar |
> 9740186063 |
>
--
Vikram Pradhan | B.Tech| Computer Science & Engineering | NIT Jalandhar |
9740186063 |
--
You received this message because you are subscribed to the Google Groups
"Algorithm Geeks" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/algogeeks?hl=en.