5,596,568 Members 41,119 Now Online
XDA Developers Android and Mobile Development Forum

Decimal to int

Tip us?
 
cdbaugher
Old
#1  
Junior Member - OP
Thanks Meter 0
Posts: 2
Join Date: Dec 2013
Default 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.
 
PicomatStudios
Old
#3  
Member
Thanks Meter 18
Posts: 77
Join Date: Sep 2012
Quote:
Originally Posted by cdbaugher View Post
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
Old
#4  
vishjoshi's Avatar
Junior Member
Thanks Meter 1
Posts: 13
Join Date: Sep 2013
Location: Junagadh
Quote:
Originally Posted by cdbaugher View Post
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
Old
#5  
coolbud012's Avatar
Senior Member
Thanks Meter 23
Posts: 194
Join Date: Sep 2012
Location: Bangalore
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.
 
EmptinessFiller
Old
#6  
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
 
PicomatStudios
Old
#7  
Member
Thanks Meter 18
Posts: 77
Join Date: Sep 2012
Quote:
Originally Posted by coolbud012 View Post
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


XDA PORTAL POSTS

Sony Xperia Z, ZL, ZR, and Tablet Z to Receive Official KitKat Update in May

It’s no secret that although Sony is one of the most … more

Force Translucent Status Bar in KitKat ROMs with Xposed

It’s been a while since Android 4.4KitKat wasreleased, and we’re slowly … more

Fix the Ambient Light Issues on Your Google Nexus 5 using Xposed

The Google Nexus 5 is a great and rather popular device. This LG-produced … more

Google Glass XE16 Update Factory Image and Rooted Bootloader Now Available

You may recall that early yesterday, we talked about the XE16 … more