Skip to content

[UNO Q} - Serial.print of a float or double prints ovf #472

Description

@KurtE

A Forum user, reported this on the Forum:
https://forum.arduino.cc/t/uno-q-println-float-or-double-results-in-ovf/1442618

I modified it slightly so I could also try running in on the GIGA (under zephyr). It worked correctly on the GIGA, but failed on the UnoQ. I am running Arduino IDE 2.3.8, current version of boards, actually I ran it using build with current sources.

#ifdef ARDUINO_UNO_Q
#include <Arduino_RouterBridge.h>
#endif
void setup() {
#ifdef ARDUINO_UNO_Q
  Bridge.begin();
#endif
  Serial.begin(115200);
}

void loop() {
  float f = 39.3;
  double d = 55.9;
  int i = 3141;
  char print_buf[128];

  Serial.print("float f = ");
  Serial.println(f); /* ovf */
  if (snprintf(print_buf, sizeof(print_buf), "float f = %f using snprintf", f)) {
    Serial.println(print_buf);
  }

  Serial.print("double d = ");
  Serial.println(d); /* ovf */
  if (snprintf(print_buf, sizeof(print_buf), "double d = %f using snprintf", d)) {
    Serial.println(print_buf);
  }

  Serial.print("int i = ");
  Serial.println(i);

  delay(10000);
}

On UNO Q:

float f = ovf
float f = 39.299999 using snprintf
double d = ovf
double d = 55.900000 using snprintf
int i = 3141

On Giga:

float f = 39.30
float f = 39.299999 using snprintf
double d = 55.90
double d = 55.900000 using snprintf
int i = 3141

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions