Here you can find the source of divide(Number n1, Number n2)
public static Number divide(Number n1, Number n2)
//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 * /*from ww w . j a va 2 s . com*/ * Contributors: * Dimitrios Kolovos - initial API and implementation ******************************************************************************/ public class Main { public static Number divide(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(); } } }