Here you can find the source of negative(Number n)
public static Number negative(Number n)
//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 . jav a 2s. c om * Contributors: * Dimitrios Kolovos - initial API and implementation ******************************************************************************/ public class Main { public static Number negative(Number n) { if (n instanceof Double) { return -n.doubleValue(); } else if (n instanceof Float) { return -n.floatValue(); } else if (n instanceof Long) { return -n.longValue(); } else { return -n.intValue(); } } }