iphone - assign double to another double with 1 number after the decimal -
this question has answer here:
- round doubles in objective-c 4 answers
i want assign value of double double, print 1 number after decimal, let have random double value , 23.12906370532668
how can converted 23.1, stay double value?? say:
nslog(@"%4.1f\n", double);
but printed string want assign new double. double 1 = 23.12906370532668;
double 2 = 23.1;
best way , how that?
am not sure trying do, want
double d = 23.12906370532668; nsstring *str = [nsstring stringwithformat:@"%4.1f\n", d]; double d2 = [str doublevalue];
Comments
Post a Comment