src/miscallenous.cpp

changeset 1223
4f8fa42aed07
parent 1222
34def2630300
child 1224
5a31b6d4bf81
--- a/src/miscallenous.cpp	Thu Jan 04 21:41:17 2018 +0200
+++ b/src/miscallenous.cpp	Thu Jan 04 22:42:01 2018 +0200
@@ -262,24 +262,9 @@
 
 // =============================================================================
 //
-void RoundToDecimals(double& a, int decimals)
+double RoundToDecimals(double value, int decimals)
 {
-	static const long e10[] =
-	{
-		1l,
-		10l,
-		100l,
-		1000l,
-		10000l,
-		100000l,
-		1000000l,
-		10000000l,
-		100000000l,
-		1000000000l,
-	};
-
-	if (decimals >= 0 and decimals < countof(e10))
-		a = round(a * e10[decimals]) / e10[decimals];
+	return std::round(value * std::pow(10, decimals)) / std::pow(10, decimals);
 }
 
 // =============================================================================

mercurial