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 1230 Posts: 2,607 Join Date: Feb 2013 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: 76
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;`

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

PicomatStudios
Member
Thanks Meter 18
Posts: 76
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)
 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

### XDA PORTAL POSTS

#### [OTA Captured] Google Glass XE16 Update Brings KitKat, Photo Bundles, Photos in Hangouts, Voice Commands Sorting, and More

Earlier today, for … more

#### Prevent Unwanted Butt Dialing with Smart Pocket Guard

You may recall that back in August of last year, we took a look atAir SwiperbyXDA … more

#### Google ATAP Details Project Ara in Developers’ Conference

Earlier today, the Google ATAP teamkicked offits first ever Project Ara … more

#### HTC Sense 6 Ported to the Nexus 5

The Google Nexus 5 is regarded as having everything an Android user needs or wants: timely updates, … more