Here you can find the source of fmodulo(double v1, double v2)
Parameter | Description |
---|---|
v1 | dividend; can be positive or negative |
v2 | divisor; must be positive |
static public double fmodulo(double v1, double v2)
//package com.java2s; /*/*from w w w . jav a2 s . c o m*/ * This file is part of Healpix Java. * * This code is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This code is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this code; if not, write to the Free Software * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA * * For more information about HEALPix, see http://healpix.jpl.nasa.gov */ public class Main { /** Returns the remainder of the division {@code v1/v2}. The result is non-negative. @param v1 dividend; can be positive or negative @param v2 divisor; must be positive @return remainder of the division; positive and smaller than {@code v2} */ static public double fmodulo(double v1, double v2) { if (v1 >= 0) return (v1 < v2) ? v1 : v1 % v2; double tmp = v1 % v2 + v2; return (tmp == v2) ? 0. : tmp; } }