Java Fraction Create frac(double number)

Here you can find the source of frac(double number)

Description

Gets the decimal portion of the given double.

License

LGPL

Declaration

public static double frac(double number) 

Method Source Code

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

public class Main {
    /**/*from w w w .j a va 2  s.  com*/
     * Gets the decimal portion of the given double. For instance, {@code frac(5.5)} returns {@code .5}.
     */
    public static double frac(double number) {
        return number - Math.floor(number);
    }

    /**
     * Returns the greatest integer less than or equal to the float argument
     */
    public static int floor(float value) {
        int i = (int) value;
        return value < (float) i ? i - 1 : i;
    }

    /**
     * Returns the greatest integer less than or equal to the double argument
     */
    public static int floor(double value) {
        int i = (int) value;
        return value < (double) i ? i - 1 : i;
    }
}

Related

  1. Frac(double value)
  2. frac(double value)
  3. Frac(double x)
  4. frac(double x)