Go Down

Topic: Non-existing sq() function (Read 1 time) previous topic - next topic

Djui

Aug 19, 2012, 11:53 am Last Edit: Aug 19, 2012, 12:02 pm by Djui Reason: 1
The http://arduino.cc/en/Reference/Sqrt documentation references the 'sq' function but online, this function is not in the index, and offline (at least on OSX) the documentation for it is non-existing neither is it in the index.

AWOL

I suspect it is omitted because it is such a trivial thing to implement oneself.
"Pete, it's a fool looks for logic in the chambers of the human heart." Ulysses Everett McGill.
Do not send technical questions via personal messaging - they will be ignored.

pito

You do not need it implement by yourself, of course, both compile with 1.0.1 fine:
 float x, y;
 x = 123.456;
 y = sqrt(x);
 Serial.println(y);
 y = sq(y);
 Serial.println(y);

Tom Carpenter

If it doesn't exist for you, you can add it by including this line at the top of your sketch:

#define sq(x) ((x)*(x))

That is all it is defined as in the Arduino.h file of Arduino 1.0.1
~Tom~

Go Up