--- a/src/misc.cpp Fri Dec 06 00:29:44 2013 +0200 +++ b/src/misc.cpp Fri Dec 06 20:53:36 2013 +0200 @@ -81,6 +81,19 @@ 3517, 3527, 3529, 3533, 3539, 3541, 3547, 3557, 3559, 3571, }; +static const int32 g_e10[] = +{ 1, + 10, + 100, + 1000, + 10000, + 100000, + 1000000, + 10000000, + 100000000, + 1000000000, +}; + // ============================================================================= // ----------------------------------------------------------------------------- // Grid stuff @@ -410,3 +423,10 @@ // one is chosen. return true; } + +// ============================================================================= +// ----------------------------------------------------------------------------- +void roundToDecimals (double& a, int decimals) +{ assert (decimals >= 0 && decimals < (signed) (sizeof g_e10 / sizeof *g_e10)); + a = round (a * g_e10[decimals]) / g_e10[decimals]; +} \ No newline at end of file