How to truncate and do not round 'double' number and convert to NSString for display

I have a double value as 1.095589665 for example. How can I convert this to a string for display and show 4 decimals without rounding? My result would be 1.0955.
dmalovichAsked:
Who is Participating?

Improve company productivity with a Business Account.Sign Up

x
 
pgnatyukConnect With a Mentor Commented:
        float number = 1.095589665;
        float x = (int)(number * 10000) / 10000.0;
        NSString *value = [NSString stringWithFormat:@"%.3f", x];
        NSLog(@"%@", value);

Open in new window


Output:
2014-01-22 10:32:09.288 round[16856:303] 1.095
0
 
dmalovichAuthor Commented:
Perfect, thank you.
0
 
pgnatyukCommented:
You are welcome
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.