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.
I don't know that ~15 or ~0xf is any clearer. ~ always worries me a little bit for some reason. I probably would have coded 0xfffffff0 but "counting nibbles" is error-prone also. Perhaps (-1) << 4 is arguably the most straightforward, but it's not obvious either. Perhaps put into a macro? Charles -----Original Message----- From: IBM Mainframe Discussion List [mailto:[email protected]] On Behalf Of David Crayford Sent: Wednesday, July 18, 2018 5:45 AM To: [email protected] 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 [email protected] with the message: INFO IBM-MAIN
