Here you can find the source of moduloPositive(final int value, final int size)
public static int moduloPositive(final int value, final int size)
//package com.java2s; /**//from w w w.j a va 2 s . co m * Copyright (c) 2008-2012 Ardor Labs, Inc. * * This file is part of Ardor3D. * * Ardor3D is free software: you can redistribute it and/or modify it * under the terms of its license which may be found in the accompanying * LICENSE file or at <http://www.ardor3d.com/LICENSE>. */ public class Main { public static int moduloPositive(final int value, final int size) { int wrappedValue = value % size; wrappedValue += wrappedValue < 0 ? size : 0; return wrappedValue; } public static float moduloPositive(final float value, final float size) { float wrappedValue = value % size; wrappedValue += wrappedValue < 0 ? size : 0; return wrappedValue; } public static double moduloPositive(final double value, final double size) { double wrappedValue = value % size; wrappedValue += wrappedValue < 0 ? size : 0; return wrappedValue; } }