Eneko
Eneko

Reputation: 159

=+ operator in Arduino

Can anybody tell me what this operation in the Arduino language is doing?

magbias = +470.;

It is not the same as magbias += 470, right?

Upvotes: 1

Views: 1121

Answers (2)

batman 1
batman 1

Reputation: 21

magbias +=470 means magbias = magbias + 470; i.e. its adds in 470 to the previous value and stores it in the same variable. magbias = +470; is defining value to the variable.

Upvotes: 0

Stephen C
Stephen C

Reputation: 718708

Anybody can tell me what is this operation doing?

The + is the unary plus operator, and it is effectively a no-op.

magbias = +470;

is equivalent to

magbias = 470;

It is not the same as magbias += 470, right?

Correct.


Normally, I would say "read the language reference", but in this case, the reference document doesn't describe the unary + or unary - operators. They are just listed in the operator precedence table.

Upvotes: 1

Related Questions