Java Number Add add(float... values)

Here you can find the source of add(float... values)

Description

Sums the given float values.

License

Open Source License

Parameter

Parameter Description
values the given values

Return

the sum

Declaration

public static float add(float... values) 

Method Source Code

//package com.java2s;
/**//  w w  w. j  a v  a  2 s .  c  o  m
 * AADL-Utils
 * 
 * Copyright ? 2012 TELECOM ParisTech and CNRS
 * 
 * TELECOM ParisTech/LTCI
 * 
 * Authors: see AUTHORS
 * 
 * This program is free software: you can redistribute it and/or modify 
 * it under the terms of the Eclipse Public License as published by Eclipse,
 * either version 1.0 of the License, or (at your option) any later version.
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
 * Eclipse Public License for more details.
 * You should have received a copy of the Eclipse Public License
 * along with this program.  If not, see 
 * http://www.eclipse.org/org/documents/epl-v10.php
 */

import java.math.BigDecimal;

public class Main {
    /**
     * Sums the given float values.
     * 
     * @param values the given values
     * @return the sum
     */
    public static float add(float... values) {
        BigDecimal res = new BigDecimal("0");

        for (float f : values) {
            BigDecimal bf = new BigDecimal(f + "");
            res = res.add(bf);
        }

        return res.floatValue();
    }
}

Related

  1. add(double v1, double v2)
  2. add(Double... ds)
  3. add(double... ds)
  4. add(final Number a, final Number b)
  5. add(final String start, final String... values)
  6. add(float[] param)
  7. add(long v1, long v2)
  8. add(long val, long augend)
  9. add(Number a, Number b)