R
Roedy Green
When you do a comparator you are supposed to return a + - or 0 int,
even if you have been comparing longs.
Lets say you have + - or 0 long and you want some sort of + 0 or 0
int.
What is the fastest way to get it.
You could do
if ( a > 0 ) return 1;
if ( a < 0 ) return -1;
return 0;
I can't come up with one liner using shift and masks that is less
complex.
if ( a == 0 ) return 0;
else return (int) ( a >>> 32);
since booleans are not bit masks, you can use them in the traditional
Forthian ways.
even if you have been comparing longs.
Lets say you have + - or 0 long and you want some sort of + 0 or 0
int.
What is the fastest way to get it.
You could do
if ( a > 0 ) return 1;
if ( a < 0 ) return -1;
return 0;
I can't come up with one liner using shift and masks that is less
complex.
if ( a == 0 ) return 0;
else return (int) ( a >>> 32);
since booleans are not bit masks, you can use them in the traditional
Forthian ways.