I have double number in a format like 34.123456789. How can I change it to 34.123?
I just want 3 digits after the decimal point.
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
You can print it to 3 decimal places with
[NSString stringWithFormat:@"%.3f",d].You can approximately round it with
round(d*1000)/1000, but of course this isn’t guaranteed to be exact since 1000 isn’t a power of 2.