Here you can find the source of mod(float a, float b)
Parameter | Description |
---|---|
a | the dividend |
b | the divisor |
public static float mod(float a, float b)
//package com.java2s; //License from project: Apache License public class Main { /**/*from w w w .j a va 2 s.co m*/ * Calculates {@code a mod b} in a way that respects negative values (for example, * {@code mod(-1, 5) == 4}, rather than {@code -1}). * * @param a the dividend * @param b the divisor * @return {@code a mod b} */ public static int mod(int a, int b) { return (a % b + b) % b; } /** * Calculates {@code a mod b} in a way that respects negative values (for example, * {@code mod(-1, 5) == 4}, rather than {@code -1}). * * @param a the dividend * @param b the divisor * @return {@code a mod b} */ public static float mod(float a, float b) { return (a % b + b) % b; } }