Here you can find the source of multiplyForLong(final Number operand1, final int operand2)
Parameter | Description |
---|---|
operand1 | The first operand, required. |
operand2 | The second operand. |
public static Long multiplyForLong(final Number operand1, final int operand2)
//package com.java2s; /*//from ww w . j a v a 2 s. co m * Copyright 2011 Eric F. Savage, code@efsavage.com * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ public class Main { /** * Multiplies an object number by a primitive int and returns a Long. * * @param operand1 * The first operand, required. * @param operand2 * The second operand. * @return The result of the multiplication as a Long. */ public static Long multiplyForLong(final Number operand1, final int operand2) { if (operand1 instanceof Double) { return Long.valueOf(Math.round(operand1.doubleValue() * operand2)); } throw new IllegalArgumentException(operand1.getClass() + " not supported"); } }