Java Number Multiply multiply(Number n1, Number n2)

Here you can find the source of multiply(Number n1, Number n2)

Description

multiply

License

Open Source License

Declaration

public static Number multiply(Number n1, Number n2) 

Method Source Code

//package com.java2s;
/*******************************************************************************
 * Copyright (c) 2012 The University of York.
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 * /* w ww.ja  va  2s. c  o m*/
 * Contributors:
 *     Dimitrios Kolovos - initial API and implementation
 ******************************************************************************/

public class Main {
    public static Number multiply(Number n1, Number n2) {
        if (n1 instanceof Double || n2 instanceof Double) {
            return n1.doubleValue() * n2.doubleValue();
        } else if (n1 instanceof Float || n2 instanceof Float) {
            return n1.floatValue() * n2.floatValue();
        } else if (n1 instanceof Long || n2 instanceof Long) {
            return n1.longValue() * n2.longValue();
        } else {
            return n1.intValue() * n2.intValue();
        }
    }
}

Related

  1. multiply(final long x, final long y)
  2. multiply(int a, int b)
  3. multiply(int x, int y)
  4. multiply(Number a, Number b)
  5. multiply(Number a, Number b, Class cl)
  6. multiply(Number n1, Number n2)
  7. multiply(V1 value1, V2 value2)
  8. multiplyForLong(final Number operand1, final int operand2)
  9. multiplyLongs(Long a, Long b)