-
-
Notifications
You must be signed in to change notification settings - Fork 7k
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
WString: add toDouble
#5362
WString: add toDouble
#5362
Conversation
`toFloat` internally converts into double and then truncates into a float, so why not add a method to return the double?
I've been trying this out today. One observation, on AVR:
So both floats and doubles are 32-bits. So, looks good to merge on AVR. Will test non-AVR cores (SAM, SAMD) shortly, since we would want to port the new API to those as well. |
@Ivan-Perez were there some particular test sketches or values you used to determine that |
I didn't know that both float and double types were the same size. I supposed that double might be 64-bit, but I've just checked it and as you say they are the same type (reference also confirms this). Then maybe this PR is not useful at all and can be closed without merging. |
Well it'll be useful for the 32-bit platforms that support a |
@Ivan-Perez thank you! @akash73 could you please add the new |
This change has been ported to the SAMD core in arduino/ArduinoCore-samd@c7c6f70, and I've also opened a pull request for the 101 core: arduino/ArduinoCore-arc32#293. |
Reviewing the code once again, I think that in case of failure both functions ( In the next days I'll create a new PR to address it. |
String::toFloat
internally converts the string into a double (usingatof
) and then truncates into afloat, so why not to add a method to return the double?