Android Int Overflow Check multiply(int x, int y)

Here you can find the source of multiply(int x, int y)

Description

Multiply two fixed-point values.

License

LGPL

Parameter

Parameter Description
x a parameter
y a parameter

Declaration

public static int multiply(int x, int y) 

Method Source Code

//package com.java2s;
/*/*from  w  w  w . j  a  v  a  2 s  .c om*/
 * Taken from android-gl, Making OpenGL Programming in Android Easier
 * URL: https://code.google.com/p/android-gl/source/browse/trunk/AndroidGL/src/edu/union/
 * 
 * License: GNU Lesser General Public License
 * 
 *   This library is free software; you can redistribute it and/or
 *   modify it under the terms of the GNU Lesser General Public
 *   License as published by the Free Software Foundation; either
 *   version 2.1 of the License, or (at your option) any later version.
 *
 *   This library is distributed in the hope that it will be useful,
 *   but WITHOUT ANY WARRANTY; without even the implied warranty of
 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 *   Lesser General Public License for more details.
 *
 *   You should have received a copy of the GNU Lesser General Public
 *   License along with this library; if not, write to the Free Software
 *   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 */

public class Main {
    /**
     * Multiply two fixed-point values.
     * 
     * @param x
     * @param y
     * @return
     */
    public static int multiply(int x, int y) {
        long z = (long) x * (long) y;
        return ((int) (z >> 16));
    }
}

Related

  1. constrain(int value, int min, int max)
  2. mulAndCheck(int x, int y)
  3. stirlingS2(final int n, final int k)
  4. subAndCheck(int x, int y)
  5. multiply(int x, int y)
  6. sqrt(int n)
  7. divide(int x, int y)