BrightSide Workbench Full Report + Source Code
Round.java
Go to the documentation of this file.
1
/*
2
* TurrĂ³ i Cutiller Foundation. License notice.
3
* Copyright (C) 2011 Lluis TurrĂ³ Cutiller <http://www.turro.org/>
4
*
5
* This program is free software: you can redistribute it and/or modify
6
* it under the terms of the GNU Affero General Public License as published by
7
* the Free Software Foundation, either version 3 of the License, or
8
* (at your option) any later version.
9
*
10
* This program is distributed in the hope that it will be useful,
11
* but WITHOUT ANY WARRANTY; without even the implied warranty of
12
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
* GNU Affero General Public License for more details.
14
*
15
* You should have received a copy of the GNU Affero General Public License
16
* along with this program. If not, see <http://www.gnu.org/licenses/>.
17
*/
18
package
org.turro.math;
19
24
public
class
Round
{
25
26
private
double
value;
27
28
public
Round
(
double
value) {
29
this.value = value;
30
}
31
32
public
Round
decimals
(
int
digits) {
33
double
tmp = Math.pow(10.0, digits);
34
value = ((double) Math.floor((value * tmp) + 0.5555555)) / tmp;
35
return
this
;
36
}
37
38
public
double
perCent
(
int
digits) {
39
value *= 100.0;
40
return
decimals
(digits).value();
41
}
42
43
public
double
value
() {
44
return
value;
45
}
46
47
/* Factory */
48
49
public
static
Round
from
(
double
value) {
50
return
new
Round
(value);
51
}
52
53
}
org.turro.math.Round
Definition:
Round.java:24
org.turro.math.Round.value
double value()
Definition:
Round.java:43
org.turro.math.Round.Round
Round(double value)
Definition:
Round.java:28
org.turro.math.Round.decimals
Round decimals(int digits)
Definition:
Round.java:32
org.turro.math.Round.from
static Round from(double value)
Definition:
Round.java:49
org.turro.math.Round.perCent
double perCent(int digits)
Definition:
Round.java:38
TurroProjects
Public
Elephant
elephant-math
src
main
java
org
turro
math
Round.java
Generated on Tue Mar 12 2024 07:01:20 for BrightSide by
1.9.1