Here you can find the source of minus(Number n)
Parameter | Description |
---|---|
n | The number to negate. |
static public Number minus(Number n)
//package com.java2s; /*/*from w w w . ja v a 2 s . c o m*/ * The contents of this file are subject to the Open Software License * Version 3.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.opensource.org/licenses/osl-3.0.txt * * Software distributed under the License is distributed on an "AS IS" * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See * the License for the specific language governing rights and limitations * under the License. */ public class Main { /** * Returns The negation of a number, regardless of its type. * @param n The number to negate. * @return Negative the number, or null if the number was null. */ static public Number minus(Number n) { if (n instanceof Long) return new Long(-n.longValue()); if (n instanceof Integer) return new Integer(-n.intValue()); if (n instanceof Short) return new Short((short) -n.shortValue()); if (n instanceof Byte) return new Byte((byte) -n.byteValue()); if (n instanceof Double) return new Double(-n.doubleValue()); if (n instanceof Float) return new Float(-n.floatValue()); return null; } }