Java String Sanitize sanitize(double[] outdata)

Here you can find the source of sanitize(double[] outdata)

Description

Sanitizes a double array, meaning - replace NaN by zero - replace -infinity by zero - replace infinity by zero

License

Open Source License

Parameter

Parameter Description
outdata data to be processed

Declaration

public static void sanitize(double[] outdata) 

Method Source Code

//package com.java2s;
//License from project: Open Source License 

public class Main {
    /**/*from   ww w . j av  a2  s .c  o  m*/
     * Sanitizes a double array, meaning - replace NaN by zero - replace
     * -infinity by zero - replace infinity by zero
     * 
     * @param outdata
     *            data to be processed
     */
    public static void sanitize(double[] outdata) {
        for (int i = 0; i < outdata.length; i++) {
            outdata[i] = outdata[i] == Double.NaN ? 0.0 : outdata[i];
            outdata[i] = outdata[i] == Double.NEGATIVE_INFINITY ? (0.0)
                    : outdata[i];
            outdata[i] = outdata[i] == Double.POSITIVE_INFINITY ? (0.0)
                    : outdata[i];
        }
    }
}

Related

  1. sanitize(char orig)
  2. sanitize(CharSequence string)
  3. sanitize(final String main)
  4. sanitize(final String name)
  5. sanitize(final String s)
  6. sanitize(final String singleOctets, byte[] dest)