mirror of
https://github.com/twiglet/cs2j.git
synced 2025-01-18 13:15:17 +01:00
sync from RS: Use support routine for rounding to fixed number of places
This commit is contained in:
parent
2c5e4afa3b
commit
7b9ab466a9
@ -1,4 +1,4 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<!--
|
<!--
|
||||||
|
|
||||||
This file is
|
This file is
|
||||||
@ -179,8 +179,10 @@
|
|||||||
<Return>System.Single</Return>
|
<Return>System.Single</Return>
|
||||||
</Method>
|
</Method>
|
||||||
<Method>
|
<Method>
|
||||||
<Imports />
|
<Imports>
|
||||||
<Java>(Math.round(${d}*Math.pow(10,${decimals})) / Math.pow(10,${decimals}))</Java>
|
<Import>CS2JNet.System.MathSupport</Import>
|
||||||
|
</Imports>
|
||||||
|
<Java>MathSupport.round(${d},${decimals})</Java>
|
||||||
<Params>
|
<Params>
|
||||||
<Param>
|
<Param>
|
||||||
<Type>System.Decimal</Type>
|
<Type>System.Decimal</Type>
|
||||||
@ -195,8 +197,10 @@
|
|||||||
<Return>System.Decimal</Return>
|
<Return>System.Decimal</Return>
|
||||||
</Method>
|
</Method>
|
||||||
<Method>
|
<Method>
|
||||||
<Imports />
|
<Imports>
|
||||||
<Java>(Math.round(${d}*Math.pow(10,${decimals})) / Math.pow(10,${decimals}))</Java>
|
<Import>CS2JNet.System.MathSupport</Import>
|
||||||
|
</Imports>
|
||||||
|
<Java>MathSupport.round(${d},${decimals})</Java>
|
||||||
<Params>
|
<Params>
|
||||||
<Param>
|
<Param>
|
||||||
<Type>System.Double</Type>
|
<Type>System.Double</Type>
|
||||||
|
@ -66,8 +66,12 @@ public class MathSupport {
|
|||||||
|
|
||||||
|
|
||||||
public static void main(String args[]) {
|
public static void main(String args[]) {
|
||||||
double f = 10.123456789d;
|
double f = 10.123456789d;
|
||||||
System.out.println(f + "turns into" + round(f,3));
|
System.out.println(f + " turns into " + round(f,3));
|
||||||
|
double g = 1.0d;
|
||||||
|
System.out.println(g + " turns into " + round(g,4));
|
||||||
|
double h = 0.7d;
|
||||||
|
System.out.println(h + " turns into " + round(h,4));
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user