Skip to content
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

Floating point format support in sprintf #1179

Closed
eng1n88r opened this issue Dec 9, 2015 · 7 comments
Closed

Floating point format support in sprintf #1179

eng1n88r opened this issue Dec 9, 2015 · 7 comments

Comments

@eng1n88r
Copy link

eng1n88r commented Dec 9, 2015

Hi,

Was working with ESP8266 and found issue with snprintf.

Here is the sample:

char _converted[33];
float value = 10;
int size = sizeof(_converted)-1;

snprintf(_converted, size, "Value is %.2f", value);
Serial.print("Core test: "); Serial.println(_converted);

Expected result was: Core test: Value is 10.00
Actual result is: Core test: Value is %.2f

Want to back this issue? Post a bounty on it! We accept bounties via Bountysource.

@igrr
Copy link
Member

igrr commented Dec 9, 2015

Please see #73.

@eng1n88r
Copy link
Author

eng1n88r commented Dec 9, 2015

Thanks for fast reply! Sorry for duplicating the issue was searching by snprintf. Will the support of float be added in future?

@igrr
Copy link
Member

igrr commented Dec 13, 2015

We are actually using vsprintf which is present in the ESP8266 ROM code. Since the code is in ROM, there is no way to extend it with FP format support.
Rolling our own implementation of sprintf (or taking one from newlib) is possible, but is pretty low on my list.

@igrr igrr changed the title Bug in snprintf Floating point format support in sprintf Dec 13, 2015
@eng1n88r
Copy link
Author

Thank you!

@tofrnr
Copy link

tofrnr commented Jun 30, 2017

char* str[100];
// not possible for AVR and nodeMCU but possible for Arduino ARM core:
sprintf(s, "floats: %4.2f %+.0e %E \n", 3.1416, 3.1416, 3.1416); 

not possible in Arduino IDE 1.8.2 feat. esp8266 board manager
when is it automatically available via Arduino IDE?

@igrr
Copy link
Member

igrr commented Jun 30, 2017

2.4.0 is in release candidate stage now (2.4.0-rc1). To test it, uninstall the existing version using boards manager, then use the boards manager URL provided in the release notes: https://github.com/esp8266/Arduino/releases/tag/2.4.0-rc1 (see "Obtaining 2.4.0-rc1 pre-release" section near the bottom of the page).

@tofrnr
Copy link

tofrnr commented Jun 30, 2017

thank you, but then I'll wait for it to come with the Arduino IDE board manager.
Do you have a release date?

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

No branches or pull requests

3 participants