Java Integer Mod moduloPositive(final int value, final int size)

Here you can find the source of moduloPositive(final int value, final int size)

Description

modulo Positive

License

Open Source License

Declaration

public static int moduloPositive(final int value, final int size) 

Method Source Code

//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;
    }
}

Related

  1. modulo(int a, int b)
  2. modulo(int dividend, int divisor)
  3. modulo(int x, int m)
  4. modulo(int x, int mod)
  5. modulo(int x, int y)
  6. moduloPowerOfTwo(final int x, final int powerOfTwoY)
  7. modulus(int a, int b)
  8. modulus(int a, int b)
  9. modulus(int value, int truncate, boolean flag)