Java mean meanLow(final int a, final int b)

Here you can find the source of meanLow(final int a, final int b)

Description

mean Low

License

Open Source License

Return

Mean without overflow, rounded to the lowest value (i.e. mathematical floor((a+b)/2), using floating point division).

Declaration

public static int meanLow(final int a, final int b) 

Method Source Code

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

public class Main {
    /**/*from   w  w w . ja v  a2  s.co m*/
     * @return Mean without overflow, rounded to the lowest value (i.e. mathematical floor((a+b)/2), using floating
     *         point division).
     */
    public static int meanLow(final int a, final int b) {
        return (a & b) + ((a ^ b) >> 1);
    }

    /**
     * @return Mean without overflow, rounded to the lowest value (i.e. mathematical floor((a+b)/2), using floating
     *         point division).
     */
    public static long meanLow(final long a, final long b) {
        return (a & b) + ((a ^ b) >> 1);
    }
}

Related

  1. meanEnt(double[] nums)
  2. meanFast(final double[] values)
  3. meanFilter(float[] weights, int context)
  4. meanGreenwichSideralTime(double t)
  5. meanImage(float[][]... images)
  6. means(double[][] input)
  7. meanSlow(final double[] values)
  8. meanSml(final int a, final int b)
  9. meanSquare(float[] a, int off, int length)