RSS Feed

How To Convert An Integer To Float And Float To String In Java And Android Studio

Sometimes you need to convert an integer to float. This is straight forward. I have made the example below much longer than your code would have to be, simply to explain.

// The integer I want to convert
int myInt = 100;

// Casting of integer to float
float newFloat = (float) myInt

// Converting float to string;
String s = String.valueOf(newFloat);

// Display string value
Toast.makeText(myView.getContext(), “Float Value of myInt = ” +s,Toast.LENGTH_LONG).show();

Easy Hey!


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: