changeset 455:caf8330369a9 draft

Avoid sprintf decimal-point localization
author Gavin Andresen <gavinandresen@gmail.com>
date Mon, 28 Feb 2011 21:34:36 +0000
parents 09c504f1f58f
children 39f8c9430b2d
files util.cpp
diffstat 1 files changed, 6 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/util.cpp
+++ b/util.cpp
@@ -313,7 +313,12 @@
 
 string FormatMoney(int64 n, bool fPlus)
 {
-    string str = strprintf("%.08f", double(n > 0 ? n : -n)/double(COIN));
+    // Note: not using straight sprintf here because we do NOT want
+    // localized number formatting.
+    int64 n_abs = (n > 0 ? n : -n);
+    int64 quotient = n_abs/COIN;
+    int64 remainder = n_abs%COIN;
+    string str = strprintf("%"PRI64d".%08"PRI64d, quotient, remainder);
 
     // Right-trim excess 0's before the decimal point:
     int nTrim = 0;