Java Double Number Round Round(double Rval, int Rpl)

Here you can find the source of Round(double Rval, int Rpl)

Description

Roundoff method.

License

Apache License

Parameter

Parameter Description
Rval double
Rpl Integer

Return

double

Declaration

public static double Round(double Rval, int Rpl) 

Method Source Code

//package com.java2s;
/**//  www  .  j  ava 2  s  . co  m
 * Copyright 2011-2016 SAYservice s.r.l.
 *
 * Licensed under the Apache License, Version 2.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.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 *
 */

public class Main {
    /**
     * Roundoff method.
     * 
     * @param Rval
     *            double
     * @param Rpl
     *            Integer
     * @return double
     */
    public static double Round(double Rval, int Rpl) {
        float p = (float) Math.pow(10, Rpl);
        Rval = Rval * p;
        float tmp = Math.round(Rval);
        return (double) tmp / p;
    }
}

Related

  1. round(double number, int precision)
  2. round(Double number, Integer precision)
  3. round(Double ret, Integer doublePrecision)
  4. round(double round, int decimal, int ceilOrFloor)
  5. round(double Rpred[][])
  6. round(double toRound)
  7. round(double v)
  8. round(double v, int precision)
  9. round(double val)