double test1 = 5.58f;
NSString *test2 = @"5.58";
NSLog(@"%@", [NSNumber numberWithDouble:test1]);
NSLog(@"%@", [NSNumber numberWithDouble:[test2 doubleValue]]);
Output:
5.579999923706055
5.58
Why the convert is difference?
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.
Probably due to the fact that 5.58f is a
float, not adouble.