chipKIT® Development Platform

Inspired by Arduino™

Serial.print

Created Fri, 26 Oct 2012 09:16:31 +0000 by ricmorte


ricmorte

Fri, 26 Oct 2012 09:16:31 +0000

For the record, does anyone know the maximum number of decimal places to which Serial.print has been designed?

To my reckoning it appears to be 15d.p. Can anyone confirm this?

Thanks, Ric

PS: as an adjunct to this, how do you print a long double?


mkirby

Tue, 30 Oct 2012 19:06:52 +0000

In order to print a long double you will need to do something like this:

long double x;

x = 1.123456789123456;

char myString[20];

sprintf(myString, "%.15lf", x);

Serial.begin(9600);

Serial.println(myString);

Using this method, you are not limited to the 15 decimal point limit of Serial.print, however, the long double is only accurate up to 15 decimal places. Hope this helps.