Java Float Number Mod mod(final float a, final float mod)

Here you can find the source of mod(final float a, final float mod)

Description

An equivalent to % for float

License

Open Source License

Parameter

Parameter Description
a a parameter
mod a parameter

Return

0 <= b < mod

Declaration

final static public float mod(final float a, final float mod) 

Method Source Code

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

public class Main {
    /**/*from  ww w. j  a v a  2 s. c o  m*/
     * An equivalent to % for float
     *
     * @param a
     * @param mod
     * @return 0 <= b < mod
     */
    final static public float mod(final float a, final float mod) {
        final float b = a - mod * (int) (a / mod);
        if (b >= 0)
            return b;
        else
            return b + mod;
    }
}

Related

  1. fmod(double a, double b)
  2. FMod(double x, double y)
  3. fmodf(Float float1, float float2)
  4. fmodulo(double v1, double v2)
  5. mod(final float a, final float b)
  6. mod(float a, float b)
  7. mod(float a, float b)
  8. mod(float a, float b)
  9. mod(float dividend, float quotient)