Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

al7zn22

macrumors newbie
Original poster
Nov 13, 2006
27
0
Hey guys I have try many type of number when I try to divide two numbers.

For example:
if I have : x = 1, and y= 1000
and I want to get a result of
0.001 if i did x/y
and
1000 if i did y/x

I try using @"%f" but it does not show it in the right way..
I know if I use @"%0.3f" it will show the answer as 0.001
but what if I have y = 10000? the answer will be 0.000
and in my case if I did y/x the answer will be 1000.000
and I only want to show the 1000

how could I do it?
 

dejo

Moderator emeritus
Sep 2, 2004
15,982
452
The Centennial State
As chown33 likes to say, "we can't debug descriptions". Please provide some code.

Also, be aware that the issue probably doesn't lie in the type of the value stored, but rather in the way you are going about outputting that value.
 

al7zn22

macrumors newbie
Original poster
Nov 13, 2006
27
0
This is my code and the result for each code is below it.

float total = 1*1000;
lable.text = [NSString stringWithFormat:mad:"%f",total];
---------------------------------------------
the result comes to : 1000.000000
and the output I want is: 1000
---------------------------------------------


float total = 1/1000;
lable.text = [NSString stringWithFormat:mad:"%f",total]
---------------------------------------------
the result comes to: 0.001000
and I want the result to be 0.001
---------------------------------------------


float total = 1/100;
lable.text = [NSString stringWithFormat:mad:"%f",total]
---------------------------------------------
the result comes to: 0.010000
and I want the result to be 0.01
---------------------------------------------
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.