Here you can find the source of euclideanMod(final float x, final float y)
public static float euclideanMod(final float x, final float y)
//package com.java2s; /*//w w w. j a v a 2s . co m * Copyright (C) 2010 Google Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); you may not * use this file except in compliance with the License. You may obtain a copy of * the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the * License for the specific language governing permissions and limitations under * the License. */ public class Main { /** * Returns Euclidean modulo of {@code x}, {@code y}. * * @see <a href="http://portal.acm.org/citation.cfm?id=128862" * target="_parent"> The Euclidean definition of the functions div and * mod</a> */ public static double euclideanMod(final double x, final double y) { final double mod = x % y; return (mod < 0) ? mod + y : mod; } /** * Returns Euclidean modulo of {@code x}, {@code y}. * * @see #euclideanMod(double, double) */ public static float euclideanMod(final float x, final float y) { final float mod = x % y; return (mod < 0) ? mod + y : mod; } }