I want to convert this string: 0.55000000000000004
to this double: 0.55
. How to do that?
In the C Programming Language, the strtod function converts a string to a double. The strtod function skips all white-space characters at the beginning of the string, converts the subsequent characters as part of the number, and then stops when it encounters the first character that isn't a number.
Using parse() For converting a String to a double, the parse() static method of double class can be used. String source, [@deprecated double onError(String source)?] );
you can use this code to reduce precision part:
double m = Math.Round(0.55000000000000004,2);
Result would be : 0.55
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With