Skip to content

dtosrtf doesn't pad to desired width #475

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
mikemacwillie opened this issue Jun 27, 2015 · 2 comments
Closed

dtosrtf doesn't pad to desired width #475

mikemacwillie opened this issue Jun 27, 2015 · 2 comments

Comments

@mikemacwillie
Copy link

The dtostrf implementation seems to be missing the leading space padding of the AVR variant. The padding is very helpful when doing things like updating LCDs.

On the 328P the following test code prints ' 17.0105' , and on the ESP8266 it prints '17.0105'.

float input = 17.0105;
char val[12];

void setup() {
Serial.begin(115200);
dtostrf(input, 11, 4, val);
Serial.print("'");
Serial.print(val);
Serial.println("'");

}

void loop() {

}

@Makuna
Copy link
Collaborator

Makuna commented Jul 10, 2015

If I read the docs correctly, your example should have output "____17.0105" (four spaces) and not "_17.0105" (one space).

@mikemacwillie
Copy link
Author

That's correct. There actually are 4 spaces in there, but it doesn't seem to be displaying properly. If I edit the post, there are indeed 4 spaces in there. The ESP8266 implementation doesn't add the leading spaces.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants