[Semibug] Need Help with C language
Jonathan Drews
jondrews at fastmail.com
Sun Oct 17 19:41:43 EDT 2021
I found the answer myself in Kernighan and Ritchie "The C Programming Language",
page 50:
expr1 op= expr2 is equivalent to expr1 = expr1 op expr2 where op is any of the
following: + - * / % << >> & ^ |. This also holds true for ksh93. Namely in ksh93
i = ( i << 1 ) is the same as i <<= 1.
On Sun, Oct 17, 2021, at 16:23, Jonathan Drews wrote:
> I think I understand what is going on. Just as i = i + 1 can be written as
> i += 1 so also can i = ( i << 1 ) be written as i <<= 1. Am I understanding that correctly?
>
> On Sun, Oct 17, 2021, at 09:47, Job Snijders wrote:
>> On Sun, Oct 17, 2021 at 09:43:40AM -0600, Jonathan Drews wrote:
>> > I know that it << 1 is a bitwise shift operation. What does it <<= 1 mean?
>>
>> This is a 'bitwise assignment operator'.
>>
>> The string '<<=' means "left shift assignment"
>>
>> https://en.wikipedia.org/wiki/Bitwise_operations_in_C
>>
>> Kind regards,
>>
>> Job
>>
>
> _______________________________________________
> Semibug mailing list
> Semibug at lists.nycbug.org
> http://lists.nycbug.org:8080/mailman/listinfo/semibug
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.nycbug.org/pipermail/semibug/attachments/20211017/f3700f16/attachment.htm>
More information about the Semibug
mailing list