This is the mail archive of the java@gcc.gnu.org mailing list for the Java project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Language extensions ?


> >>>>> "Robin" == Robin Garner <robin dot garner at iname dot com> 
writes:
> 
> Robin> Sadly, the only way to compare signed integers in 
an unsigned
> Robin> way is:
> Robin> boolean GT(int a, int b) {
> Robin>   if( a > 0 && b > 0 ||  a < 0 && b < 0 )  
> Robin>     return a > b;
> Robin>   else
> Robin>     return a < b;
> Robin> }
> 
> Sounds like a puzzle :-)
> 
> How about
> 
> boolean GT(int a, int b) {
>   return (((long) a) & 0xffffffffL) > (((long) b) & 
0xffffffffL);
> }

Nice try :)  How about unsigned comparison on longs (for 64 
bit architectures) ?


-- 
__________________________________________________________
Sign-up for your own FREE Personalized E-mail at Mail.com
http://www.mail.com/?sr=signup


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]