Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Increase buffer size for converting floats + doubles to String's #5369

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

Open
sandeepmistry wants to merge 1 commit into arduino:master
base: master
Choose a base branch
Loading
from sandeepmistry:max-dbl

Conversation

Copy link
Contributor

@sandeepmistry sandeepmistry commented Sep 14, 2016

Port of arduino/ArduinoCore-samd#163

Troublesome sketch:

#include <float.h> 
void setup() {
 Serial.begin(9600);
 while (!Serial);
 Serial.println(String(FLT_MAX));
 Serial.println(String(DBL_MAX));
 Serial.println(String(-FLT_MAX));
 Serial.println(String(-DBL_MAX));
}
void loop() {
}

{
init();
char buf[33];
char buf[FLT_MAX_10_EXP + 4 + decimalPlaces]; // +4, one for: 10, -, ., 0円
Copy link
Collaborator

@matthijskooijman matthijskooijman Nov 23, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What do you mean with "10" there? I can understand how -, . and 0円 are added to the number of digits that FLT_MAX_10_EXP represents, but not what 10 means.

Copy link

@darrylp1per darrylp1per Nov 24, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

10 as in ascii 10, being a LineFeed perhaps ?

Copy link
Contributor Author

@sandeepmistry sandeepmistry Nov 24, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

On AVR DBL_MAX_10_EXP is 38 and Serial.println(String(-DBL_MAX)); prints out -340282350000000000000000000000000000000.00.

Which is 43 characters in length, then you need an extra byte for the 0円, which brings us to 44.

44 - 38 - 2 = 4. Maybe, I was thinking the extra character was for the 1's digit ...

Copy link
Member

facchinm commented Feb 9, 2017

Partially moved to arduino/ArduinoCore-sam#32

Copy link
Contributor

❌ Build failed.

@facchinm facchinm added the Print and Stream class The Arduino core library's Print and Stream classes label Feb 28, 2017
@facchinm facchinm removed this from the Release 1.8.2 milestone Feb 28, 2017
@facchinm facchinm added this to the Release 1.8.3 milestone Mar 20, 2017
@cmaglie cmaglie modified the milestones: Release 1.8.3, Next Jul 18, 2017
Copy link

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.
You have signed the CLA already but the status is still pending? Let us recheck it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Reviewers

@matthijskooijman matthijskooijman matthijskooijman left review comments

+1 more reviewer

@darrylp1per darrylp1per darrylp1per left review comments

Reviewers whose approvals may not affect merge requirements
Assignees
No one assigned
Labels
Print and Stream class The Arduino core library's Print and Stream classes
Projects
None yet
Milestone
Next
Development

Successfully merging this pull request may close these issues.

AltStyle によって変換されたページ (->オリジナル) /