What is the correct way of represent double value as NSString ? In my code, it is calculating or rather doing some kind of rounding..I am not sure. Below is my code;
X = [NSString stringWithFormat:@"%d", [abc doubleValue] - [xyz doubleValue]];
I am getting abc is 69206000000, xyz is 31687000000, X is 58720256
Please help me.
Use the %f
format modifier to display a double value - the %d
in your code refers to an integer value. (See String Format Specifiers for more info.)
Use %lf
for double value
X = [NSString stringWithFormat:@"%lf", [abc doubleValue] - [xyz doubleValue]];
Hope this will help you.
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