arduino / arduino/ArduinoCore-sam
Serial.print causes ovf when printing doubles > 10 decimal digits (Due)
- Dominant language
- HTML
- Stars
- 91
- Forks
- 112
- PR merge metrics
- No merged PRs in 30d
Description
Serial.print causes ovf when printing doubles > 10 decimal digits (Due)
(AVR not tested but probably similar)
```
void setup() {
// put your setup code here, to run once:
Serial.begin(115200);
char str[30];
double f1=1234567.66;
double f2=12345678.66;
double f3=123456789.66;
double f4=1234567890.66;
double f5=12345678901.66;
Serial.println( f1 );
Serial.println( f2 );
Serial.println( f3 );
Serial.println( f4 );
Serial.println( f5 );
sprintf(str, "%.2f", f5 );
Serial.println(str);
}
void loop() {
// put your main code here, to run repeatedly:
}
```
output:
1234567.66
12345678.66
123456789.66
1234567890.66
ovf
12345678901.66
Contributor guide
No contributing guide indexed for this repository
Research direction
Reproduce the supplied sketch on an Arduino Due and compare the Serial.println outputs with sprintf(str, "%.2f", f5) and Serial.println(str). Start at the Serial.print/Serial.println handling for double values; done means the supplied values no longer produce "ovf" when printed directly and match the working formatted output.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- arduino, cpp
- Domain
- embedded-iot
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 38/100