Java Float Number Round round(float f, int i)

Here you can find the source of round(float f, int i)

Description

Round a number to "i" digits after the comma

License

Open Source License

Parameter

Parameter Description
f a parameter
i a parameter

Declaration

public static float round(float f, int i) 

Method Source Code

//package com.java2s;

public class Main {
    /**//w  ww .  j a v  a  2s . co m
     * Round a number to "i" digits after the comma
     * @param f
     * @param i
     */
    public static float round(float f, int i) {

        int x = (int) (f * i);
        float f2 = (float) x / (float) i;

        return f2;

    }
}

Related

  1. round(float a)
  2. round(float amount, int cent)
  3. round(float axisValue)
  4. round(float d)
  5. round(float f, int dp)
  6. round(float f, int n)
  7. round(float input)
  8. round(float input)
  9. round(float number, int fractionalPartSize)