square and itoa dont work on ARDUINO DUE

I dont know why on ARDUINO DUE the square (math library) fubction and the itoa(stdio library) function do not work.
Any solution?
(I Know...use pow or rewrite the function..but why they dont work ????? :relaxed:)
Thank you very much!!!


There is a library problem when using IDE V1.5.1r2 and the Due. I had the same problem with the itoa() function on the Due while the IDE would work ok with the Mega. The quickest solution is to switch to the sprintf() function. This function allows you to combine text with converted integers.

Good, Thak you very much!!!!


There's no mention of a square function in the Arduino reference at Arduino - Home, but it's easy enough to define a C macro to do it.

An itoa function is available if you #include the file itoa.h.

The sketch below uses itoa and square and works as expected with a Due and Arduino 1.5.1r2.


#include "itoa.h"
#include "Print.h"

template inline Print &operator <<(Print &obj, T arg) { obj.print(arg); return obj; }
#define square(x) pow(x, 2)

int count = 1;
int ledPin = 13; // LED connected to digital pin 13

// Run once, when the sketch starts.
void setup()
count = 0;

// initialize the digital pin as an output:
pinMode(ledPin, OUTPUT);

void loop()
String s;
char temp[20];

Serial << "Blink: Loop " << count << ", " << itoa(count, temp, 10) << ", " << square(count) << (char)10;

digitalWrite(ledPin, HIGH);
digitalWrite(ledPin, LOW);


Thank you , I''l try this solution!

There is no referce about square in the Arduino reference at Arduino - Home because of is defined in math.h Arduino - Home, but is for AVR...