Java Fraction Create frac(float x)

Here you can find the source of frac(float x)

Description

frac

License

Open Source License

Declaration

public static float frac(float x) 

Method Source Code

//package com.java2s;
//License from project: Open Source License 

public class Main {
    public static float frac(float x) {
        return x - trunc(x);
    }//from   ww  w.  ja  v  a2 s .  c  o  m

    public static float trunc(float x) {
        if (x < 0) {
            return (float) Math.ceil(x);
        } else {
            return (float) Math.floor(x);
        }
    }
}

Related

  1. frac(double number)
  2. Frac(double value)
  3. frac(double value)
  4. Frac(double x)
  5. frac(double x)
  6. frac(int f)
  7. fraction(double decimal, double tolerance)
  8. fraction(double number)
  9. fraction(int denominator)