Java Double Number mod modArray(double value, int mod, int div)

Here you can find the source of modArray(double value, int mod, int div)

Description

Return an array of long values.

License

LGPL

Parameter

Parameter Description
value a parameter
mod a parameter
div a parameter

Declaration

public static long[] modArray(double value, int mod, int div) 

Method Source Code

//package com.java2s;
//License from project: LGPL 

public class Main {
    /**/*  w  ww .  j  a va2  s  .  c o m*/
     * Return an array of long values. Length of array is "mod" value.
     *
     * @param value
     * @param mod
     * @param div
     * @return
     */
    public static long[] modArray(double value, int mod, int div) {
        final long[] result = new long[mod];
        if (result.length > 0) {
            result[0] = 100;
            if (result.length > 1) {
                final long base = ((long) (value / (mod * div))) * div;
                final long last = (long) (value - base * (mod - 1));
                for (int i = 0; i < result.length; i++) {
                    if (i == result.length - 1) {
                        result[i] = last;
                    } else {
                        result[i] = base;
                    }
                }
            }
        }
        return result;
    }
}

Related

  1. mod(double x, double y)
  2. mod(double x, double y)
  3. mod(final double a, final double b)
  4. mod2pi(double vin)
  5. mod2pi_pos(double vin)
  6. modifiedGramSchmidt(double[][] s)
  7. modifiedJulianToJulian(double modifiedJulian)
  8. modifySize(double[] x, int newLen)
  9. modPI2(double angle)