NEWS Forum Wiki XDA TV

# Decimal to int

Tip us?
 cdbaugher 8th December 2013, 12:50 AM Junior Member - OP Thanks Meter 0 Posts: 2 Join Date: Dec 2013 Decimal to int I'm try to create a app to track my reps sales but I can't figure out how to get int to use 0.0 example int points; points = 0; This works but how would I get it to register 0.0 instead 0 Thanks for your help. I'm still kinda new at this. REPLY
 nikwen 8th December 2013, 10:09 AM Recognized Contributor Thanks Meter 1235 Posts: 2,615 Join Date: Feb 2013 More Info > What's about this? Code: ```int points; points = (int) 0.0;``` This will cut off all decimals. If you want to have the decimals, use double instead of int. REPLY

PicomatStudios
Member
Thanks Meter 18
Posts: 77
Join Date: Sep 2012
Quote:
 Originally Posted by cdbaugher I'm try to create a app to track my reps sales but I can't figure out how to get int to use 0.0 example int points; points = 0; This works but how would I get it to register 0.0 instead 0 Thanks for your help. I'm still kinda new at this.

An int is an integer (so, no fractional part)
For a floating point number, you'll need something else.

float is one option
Code:
`float points = 0.0f;`
This may be worth reading.

vishjoshi
Junior Member
Thanks Meter 1
Posts: 13
Join Date: Sep 2013
Quote:
 Originally Posted by cdbaugher I'm try to create a app to track my reps sales but I can't figure out how to get int to use 0.0 example int points; points = 0; This works but how would I get it to register 0.0 instead 0 Thanks for your help. I'm still kinda new at this.
Use Double, it can store the decimal values in it. Int cannot store the decimal values.
 coolbud012 10th December 2013, 06:54 PM Senior Member Thanks Meter 23 Posts: 194 Join Date: Sep 2012 Location: Bangalore More Info > use double instead of float...that will give you 0.0 instead of 0... Aptitude Cracker - An Application for all Competitive Exams and all In One Aptitude Preparation --------------------------------------------------------------------------------------------------------------------------------- DroidAcid - Get all android tutorials and Micromax CanvasHD A116 guides. REPLY
 EmptinessFiller 10th December 2013, 08:52 PM Member Thanks Meter 21 Posts: 88 Join Date: Sep 2013 I say 0 is exactly the same like 0.0 But you can change the look when turn it to string: String.format(...) Regards REPLY

PicomatStudios
Member
Thanks Meter 18
Posts: 77
Join Date: Sep 2012
Quote:
 Originally Posted by coolbud012 use double instead of float...that will give you 0.0 instead of 0...
double and float are both floating point representations (64 bit vs 32 bit)

 Thread Tools Search this Thread Search this Thread: Advanced Search Display Modes Linear Mode