开发者

Why my app is not displaying decimal points even know i am using float value

开发者 https://www.devze.com 2023-04-02 00:31 出处:网络
I am putting the finishing touches on开发者_Python百科 my app and for some reason the values are not being shown as a decimal value.

I am putting the finishing touches on开发者_Python百科 my app and for some reason the values are not being shown as a decimal value.

if ( row == 0 ) {

    float number1 = ([initamount.text floatValue ]);
    initamount.text = [[NSString alloc]initWithFormat:@"%2.f Yard", number1];
    double answer = number1 *3;
    result.text = [[NSString alloc]initWithFormat:@"%2.f Feet", answer];

}

here is the code i am really tired and could be missing something.


Correct format string should be (note that desired precision should come after '.' in format specifier)

@"%.2f Yard"
0

精彩评论

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