On 19/07/2018 12:18 AM, Charles Mills wrote:
I thought -16 was kind of cool. It took me a second, but in the future I would 
"get" an & with -8 or -4 in a heartbeat.

It just looks wrong to me ;)

I don't know that ~15 or ~0xf is any clearer. ~ always worries me a little bit 
for some reason.

Why does it worry you? To the majority of C programmers it's the natural way of ANDing bits.

If you put your assembler programmers hat on

flag &= ~(BIT1)

isn't too dissimilar to

NI FLAG1,X'FF'-BIT1

I probably would have coded 0xfffffff0 but "counting nibbles" is error-prone 
also.

Much better IMO!

Perhaps (-1) << 4 is arguably the most straightforward, but it's not obvious 
either. Perhaps put into a macro?

Personally, I find that obscure.

Charles


-----Original Message-----
From: IBM Mainframe Discussion List [mailto:IBM-MAIN@LISTSERV.UA.EDU] On Behalf 
Of David Crayford
Sent: Wednesday, July 18, 2018 5:45 AM
To: IBM-MAIN@LISTSERV.UA.EDU
Subject: Re: S0C6 in CSRC4RG1

On 18/07/2018 8:26 PM, Steve Smith wrote:
Nice...

So, you say 1s-complement is better than 2s-complement?  Is ~15 clearer
than -16?  ;-)
I say it's best to stick to the idioms of the language you're coding in :)

My "native" language is assembler, and it doesn't have an easy way to
specify the former.
Bit twiddling in C can be tricky and not as intuitive as assembler. But
it's trivial to write macros to make it easy.

----------------------------------------------------------------------
For IBM-MAIN subscribe / signoff / archive access instructions,
send email to lists...@listserv.ua.edu with the message: INFO IBM-MAIN

----------------------------------------------------------------------
For IBM-MAIN subscribe / signoff / archive access instructions,
send email to lists...@listserv.ua.edu with the message: INFO IBM-MAIN

Reply via email to