Pages: [1]   Go Down
Author Topic: Non-existing sq() function  (Read 1136 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Newbie
*
Karma: 0
Posts: 1
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
« Last Edit: August 19, 2012, 05:02:19 am by Djui » Logged

Global Moderator
UK
Offline Offline
Brattain Member
*****
Karma: 300
Posts: 26219
I don't think you connected the grounds, Dave.
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I suspect it is omitted because it is such a trivial thing to implement oneself.
Logged

"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.

Rapa Nui
Offline Offline
Edison Member
*
Karma: 60
Posts: 2071
Pukao hats cleaning services
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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);
Logged

Leeds, UK
Offline Offline
Edison Member
*
Karma: 80
Posts: 1726
Once the magic blue smoke is released, it won't go back in!
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

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
Logged

~Tom~

Pages: [1]   Go Up
Jump to: