Java Float Number Create toFloat(long intPart, long decimalPart, long decimalPlaces)

Here you can find the source of toFloat(long intPart, long decimalPart, long decimalPlaces)

Description

to Float

License

LGPL

Declaration

public static Float toFloat(long intPart, long decimalPart, long decimalPlaces) 

Method Source Code

//package com.java2s;
//License from project: LGPL 

public class Main {
    public static Float toFloat(long intPart, long decimalPart, long decimalPlaces) {
        if (intPart < 0 || decimalPart < 0 || decimalPlaces < 0)
            return null;

        if (decimalPart == 0 || decimalPlaces == 0) {
            return Float.valueOf(intPart);
        }// w  w  w .  j a va 2 s  . co m

        float divisor = (float) Math.pow(10, decimalPlaces);
        return Float.valueOf(((float) intPart) + (((float) decimalPart) / divisor));
    }
}

Related

  1. toFloat(int hbits)
  2. toFloat(int majorVersion, int minorVersion)
  3. toFloat(int value)
  4. toFloat(int x)
  5. toFloat(int[] array)
  6. toFloat(Number value)
  7. toFloat(Object _inStrObj)
  8. toFloat(Object anObj)
  9. toFloat(Object literal)