Java Number Negate negative(Number n)

Here you can find the source of negative(Number n)

Description

negative

License

Open Source License

Declaration

public static Number negative(Number n) 

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
 * //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();
        }
    }
}

Related

  1. negateExpression(String expression)
  2. negateInPlace(float[] in)
  3. Negation(String StartIP, String netmask)
  4. negative(float a)
  5. negative(int b)
  6. negativeInf()
  7. negativePart(final double[] data)
  8. negativeStatistics(double[] array)