java to squeak conversation

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

java to squeak conversation

Robert Withers
I still have some rot in my head, from too much java, and so I don't
think consistently clearly, it's more cyclic I've noticed. As a result,
my eyes are doing back-flips when looking at this code; perhaps I need
eine kleine pause...does anyone else want to try it?

     int termPlus1 = ((term & 0x1) == 0) ? (term | 1) : (term & ~1);

cheers,
Robert

ps. an example of Java conciseness, dear God.

Reply | Threaded
Open this post in threaded view
|

Re: java to squeak conversation

Nicolas Cellier
Hi,

((term & 0x1) ==0) just test if least significant bit is unset
? (term | 1) will set the LSB to 1 if unset
: (term & ~1) will unset the LSB if set

so, all it does is (term bitXOr: 1), that is it changes the LSB of term...

The name termPlus1 is misleading.

2015-12-06 4:41 GMT+01:00 Robert Withers <[hidden email]>:
I still have some rot in my head, from too much java, and so I don't think consistently clearly, it's more cyclic I've noticed. As a result, my eyes are doing back-flips when looking at this code; perhaps I need eine kleine pause...does anyone else want to try it?

    int termPlus1 = ((term & 0x1) == 0) ? (term | 1) : (term & ~1);

cheers,
Robert

ps. an example of Java conciseness, dear God.