Skip to content

Issue with sprintf and float values #73

Closed
@ghost

Description

Using this sketch::

include <stdio.h>

void setup() {
Serial.begin(19200);
}

void loop() {
char string[40];

string[0]=0;
sprintf(string,"Characters: %c %c", 'a',65);
Serial.println(string);

string[0]=0;
sprintf(string,"Decimals: %d %ld", 1977, 650000L);
Serial.println(string);

string[0]=0;
sprintf(string,"%s", "A string");
Serial.println(string);

string[0]=0;
sprintf(string,"floats: %4.2f %+.0e %E",3.1416, 3.1416, 3.1416);
Serial.println(string);

delay(1000);
}

Results in this output;

Characters: a A
Decimals: 1977 650000
A string
floats: %.2f %.0e %E

As you can see, the sprintf function is working for %d, %s, %c but not %f

Using latest github version, downloaded today (april 16th)

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions