Loading...
Pages: [1]   Go Down
Author Topic: Non-existing sq() function  (Read 558 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: 138
Posts: 19067
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.

Rapa Nui
Offline Offline
God Member
*****
Karma: 16
Posts: 888
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
God Member
*****
Karma: 35
Posts: 983
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
Print
 
Jump to: