Skip to content

Serial.print causes ovf when printing doubles > 10 decimal digits (Due) #88

@tofrnr

Description

@tofrnr

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions