Is the a way to format the decimal number outputted by Serial.println?
in the example below you see the outputs look like this:
3.1415926536
3.1415900000
but I would like them to look like this:
3.1415926
3.14159
in C++ you can format the output with formatting codes however I only see DEC as the decimal format with no additional arguments for number of digits.
#include <stdio.h>
boolean firsttime;
double value = 3.1415926535898;
double value2 =3.14159;
void setup() {
// put your setup code here, to run once:
Serial.begin(9600);
firsttime= true;
}
void loop() {
// put your main code here, to run repeatedly:
if(firsttime==true){
firsttime=false;
Serial.println(value, DEC);
Serial.println(value2, DEC);
}
}