split float in Java Android

android, java

Solution

You can also try this

double value = 2.75;
double fraction=value%1;//Give you 0.75 as remainder 
int integer=(int)value;//give you 2 fraction part will be removed

NOTE: As result may very in `fraction` due to use of `double`.You better use

float fraction=(float) (value%1);

if `fractional` part is big.

Problem

I have a number like 2.75. I want to split this number into two other floats. Here is an example of what I am searching for: ``` value = 2.75 value2 = 2.0 value3 = 0.75 ``` I need them in my algorithm, so how could I implement this? I found `split()` but it returns string. I need floats or integer at least.

Original source