Here you can find the source of Round(double Rval, int Rpl)
Parameter | Description |
---|---|
Rval | double |
Rpl | Integer |
public static double Round(double Rval, int Rpl)
//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; } }