diff options
author | Daniel Wilhelm <daniel@wili.li> | 2016-03-16 21:31:24 +0100 |
---|---|---|
committer | Daniel Wilhelm <daniel@wili.li> | 2016-03-16 21:31:24 +0100 |
commit | 89621addb4a7c87d2e3f3e7462e3c690cf71de71 (patch) | |
tree | 008b5dea7624ee1eeb57ff82c45fdf1afcab3b08 /zen/format_unit.cpp | |
parent | 7.5 (diff) | |
download | FreeFileSync-89621addb4a7c87d2e3f3e7462e3c690cf71de71.tar.gz FreeFileSync-89621addb4a7c87d2e3f3e7462e3c690cf71de71.tar.bz2 FreeFileSync-89621addb4a7c87d2e3f3e7462e3c690cf71de71.zip |
7.6
Diffstat (limited to 'zen/format_unit.cpp')
-rw-r--r-- | zen/format_unit.cpp | 19 |
1 files changed, 14 insertions, 5 deletions
diff --git a/zen/format_unit.cpp b/zen/format_unit.cpp index 9624458c..e9c686aa 100644 --- a/zen/format_unit.cpp +++ b/zen/format_unit.cpp @@ -8,12 +8,12 @@ #include "basic_math.h" #include "i18n.h" #include "time.h" -#include "int64.h" #include <cwchar> //swprintf #include <ctime> #include <cstdio> #ifdef ZEN_WIN + #include "int64.h" #include "win.h" //includes "windows.h" #include "win_ver.h" @@ -25,9 +25,18 @@ using namespace zen; +std::wstring zen::formatTwoDigitPrecision(double value) +{ + //print two digits: 0,1 | 1,1 | 11 + if (numeric::abs(value) < 9.95) //9.99 must not be formatted as "10.0" + return printNumber<std::wstring>(L"%.1f", value); + return numberTo<std::wstring>(numeric::round(value)); +} + + std::wstring zen::formatThreeDigitPrecision(double value) { - //print at least three digits: 0,01 | 0,11 | 1,11 | 11,1 | 111 + //print three digits: 0,01 | 0,11 | 1,11 | 11,1 | 111 if (numeric::abs(value) < 9.995) //9.999 must not be formatted as "10.00" return printNumber<std::wstring>(L"%.2f", value); if (numeric::abs(value) < 99.95) //99.99 must not be formatted as "100.0" @@ -197,7 +206,7 @@ private: return inst; } - IntegerFormat() : fmt(), valid_(false) + IntegerFormat() { //all we want is default NUMBERFMT, but set NumDigits to 0 fmt.NumDigits = 0; @@ -224,10 +233,10 @@ private: } } - NUMBERFMT fmt; + NUMBERFMT fmt = {}; std::wstring thousandSep; std::wstring decimalSep; - bool valid_; + bool valid_ = false; }; } #endif |