Here you can find the source of modulus(int value, int truncate, boolean flag)
Parameter | Description |
---|---|
value | a parameter |
truncate | a parameter |
public static int modulus(int value, int truncate, boolean flag)
//package com.java2s; //License from project: Apache License public class Main { /**/* w w w . j av a2 s.c o m*/ * * @param value * @param truncate * @return modulus value equivalent to python modulus */ public static double modulus(double value, double truncate) { double newValue = value % truncate; // to get the same result as python (%) gives if (newValue < 0) { newValue += truncate; } return newValue; } /** * * @param value * @param truncate * @return modulus value equivalent to python modulus */ public static int modulus(int value, int truncate, boolean flag) { int newValue = value % truncate; // to get the same result as python (%) gives while (newValue < 0) { newValue += truncate; } return newValue; } }