[CLN-list] doc: "Obfuscating operators"
Ron Garret
ron at flownet.com
Wed Jan 23 09:43:17 CET 2008
On Jan 22, 2008, at 11:46 PM, Joerg Arndt wrote:
> * Ron Garret <ron at flownet.com> [Jan 23. 2008 14:17]:
>>
>> On Jan 22, 2008, at 3:07 PM, Bruno Haible wrote:
>>
>>> Richard B. Kreckel wrote:
>>>>> For me the shortcut operators
>>>>> as in a+=b are more readable than the long a=a+b form.
>>>>
>>>> I do admit that I find the shortcuts more readable, too.
>>>
>>> I think it depends. When you are summing up a power series,
>>>
>>> sum += factor/(2*n+1)
>>>
>>> makes perfect sense. But I also have seen things like this:
>>>
>>> x += x >> 2;
>>>
>>> which really is less readable than
>>>
>>> x = 1.25 * x;
>>
>> <puzzlement> Don't those two statements do different things? </
>> puzzlement>
>
> yes-ish:
> the first should rather be used for integers (as a matter of style).
>
> If used for floats
I'm missing something really basic here. Isn't the >> operator a
bitwise-right-shift and hence defined only for integers?
rg
More information about the CLN-list
mailing list