General Question

gorillapaws's avatar

C++/Arduino programmers, can you help me understand this line of code?

Asked by gorillapaws (26741points) September 22nd, 2020

I’m just starting to dip my little toe into arduinos and maybe some hobbyist robotics. I was looking at the driver for an Arduino device and I came across the following line:


then there’s:


If you’re doing a left bit-shift by a value of 0, what’s the point? why not just define it as “0×1”? This is a driver, so they’re defining the response from the device. It just seems very counter intuitive. I suspect that there is an important concept underlying that code that I don’t understand and since I’m not sure what that is, I’m not sure what keywords I should be searching to figure it out.

Any help would be greatly appreciated.

Observing members: 0 Composing members: 0

1 Answer

Zaku's avatar

It’s for consistency and code readability, to communicate intent and patterns clearly.

Other #defines undoubtedly bit-shift by values other than zero, so this clarifies what the intent is.

Except when someone thinks the way you’ve been thinking about it. ;-)

Answer this question




to answer.

This question is in the General Section. Responses must be helpful and on-topic.

Your answer will be saved while you login or join.

Have a question? Ask Fluther!

What do you know more about?
Knowledge Networking @ Fluther