开发者

Some maths questions on Obj-C

I just have two questions on Obj-C. I have a string value: "234.67". How can i change the dot to comma? Resulting 234开发者_如何学C,67?

Another questions is, how work the split/division on Obj-C? I have a value, 255.45 and i want to divide it twelve times.

Thanks!


To replace the period with a comma, you should replace it in the string when you want to display it.

NSString *str = @"234.67";

str = [str stringByReplacingOccurrencesOfString:@"."
                                     withString:@","];

To divide you just use the operator

float j;

j = 234.67 / 12;

Good Luck.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜