Advertise Mobile SDKs Books Events Forum News Social Networking Support Us
Follow @iphonedevsdk on Twitter

Interface 2, Advanced iOS
Mockup & Code Gen
($9.99)

Make your own iPhone apps
and run them live!
(free)

Pic Frame Dynamo: Photo Editing
($0.99)

Abiliator
($1.99)

Want your application or service advertised on iPhone Dev SDK?

Go Back   iPhone Dev SDK Forum > iPhone SDK Development Forums > iPhone SDK Development

Reply
 
LinkBack Thread Tools Display Modes
Old 09-12-2010, 04:10 PM   #1 (permalink)
Registered Member
 
Join Date: Jun 2010
Posts: 4
altamimi22 is on a distinguished road
Default Which one to use? Double/Double or Float/Float? and how could I show it in strin

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?
altamimi22 is offline   Reply With Quote
Old 09-12-2010, 07:12 PM   #2 (permalink)
Registered Member
 
Join Date: Jun 2009
Location: Ypsilanti, Michigan
Age: 63
Posts: 1,549
RLScott is on a distinguished road
Default

Quote:
Originally Posted by altamimi22 View Post
....how could I do it?
You have not made clear what you think is the right way to display the various numbers you might get.
RLScott is offline   Reply With Quote
Old 09-12-2010, 09:57 PM   #3 (permalink)
Registered Member
 
Join Date: Jun 2010
Posts: 4
altamimi22 is on a distinguished road
Default

Quote:
Originally Posted by RLScott View Post
You have not made clear what you think is the right way to display the various numbers you might get.
sorry,
this is what I want:


This is my code and the result for each code is below it.

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


float total = 1/1000;
lable.text = [NSString stringWithFormat:@"%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:@"%f",total]
---------------------------------------------
the result comes to: 0.010000
and I want the result to be 0.01
---------------------------------------------

I want to have one code for all of them, and it should auto detect how many digits it should be.
altamimi22 is offline   Reply With Quote
Old 09-13-2010, 12:49 AM   #4 (permalink)
Registered Member
 
Join Date: Jun 2010
Posts: 4
altamimi22 is on a distinguished road
Default

Thanks I just solve it
altamimi22 is offline   Reply With Quote
Reply

Bookmarks

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



» Advertisements
» Online Users: 342
11 members and 331 guests
cgokey, fiftysixty, givensur, iGamesDev, jenniead38, linkmx, mraalex, PixelInteractive, raihan.zbr, Trickphotostudios
Most users ever online was 1,387, 04-10-2012 at 04:21 AM.
» Stats
Members: 175,657
Threads: 94,116
Posts: 402,889
Top Poster: BrianSlick (7,990)
Welcome to our newest member, jenniead38
Powered by vBadvanced CMPS v3.1.0

All times are GMT -5. The time now is 12:02 AM.
Powered by vBulletin® Version 3.8.0
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.3.0