aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorlogin <login@tilde.team>2023-11-23 07:54:57 +0000
committerlogin <login@tilde.team>2023-11-23 07:54:57 +0000
commit478534343c42e53460de85b596b55bdecd4115e4 (patch)
tree3cf1cf33775d4ad9ccb7747a3a44d77313a57e8c
parent5128e4408d51d5d35af008fe8212a2ddde3bd798 (diff)
downloadtcoin-478534343c42e53460de85b596b55bdecd4115e4.tar.gz
Fixed bug in thousands separator
When the input is 0, the thousands-separator function was sending nothing. Now, it sends 0.
-rw-r--r--tcoin.cpp14
1 files changed, 10 insertions, 4 deletions
diff --git a/tcoin.cpp b/tcoin.cpp
index e3bde74..42660c6 100644
--- a/tcoin.cpp
+++ b/tcoin.cpp
@@ -379,6 +379,12 @@ std::string get_username()
void num_stream_thousands_sep(std::ostringstream& ss, long long int const& amount, char sep=',')
{
+ if(amount == 0)
+ {
+ ss << 0;
+ return;
+ }
+
std::ostringstream rev;
long long int reduced_amount = amount/1000;
int residue = amount % 1000;
@@ -388,8 +394,8 @@ void num_stream_thousands_sep(std::ostringstream& ss, long long int const& amoun
int num_residue_digits = residue_gte_100 + residue_gte_10 + residue_gte_1;
- int mini_reduced_amount = amount/10;
- int mini_residue = amount % 10;
+ int mini_reduced_amount = residue/10;
+ int mini_residue = residue % 10;
do
{
@@ -415,8 +421,8 @@ void num_stream_thousands_sep(std::ostringstream& ss, long long int const& amoun
residue_gte_1 = residue >= 1;
num_residue_digits = residue_gte_100 + residue_gte_10 + residue_gte_1;
- mini_reduced_amount = reduced_amount/10;
- mini_residue = reduced_amount % 10;
+ mini_reduced_amount = residue/10;
+ mini_residue = residue % 10;
reduced_amount = reduced_amount/1000;
} while(reduced_amount > 0);