1
0
forked from Alepha/Alepha

Fix bug in number printing.

This commit is contained in:
2024-08-08 17:13:13 -04:00
parent 9eaf05c36c
commit 307175b616
2 changed files with 16 additions and 8 deletions

View File

@ -78,17 +78,21 @@ namespace Alepha::Hydrogen::Utility ::detail:: print_number_m
value/= 1000; value/= 1000;
if( not remainder ) continue; if( not remainder ) continue;
std::string next; std::string next;
if( remainder >= 100 ) next+= names.at( remainder / 100 ) + " hundred "; if( remainder >= 100 ) next+= names.at( remainder / 100 ) + " hundred";
remainder%= 100; remainder%= 100;
if( remainder )
{
next+= " ";
if( remainder >= 20 ) if( remainder >= 20 )
{ {
next+= tens.at( remainder - remainder % 10 ); next+= tens.at( remainder - remainder % 10 );
if( remainder % 10 ) next+= " " + names.at( remainder % 10 ); if( remainder % 10 ) next+= " " + names.at( remainder % 10 );
} }
else if( remainder ) else
{ {
next+= names.at( remainder ); next+= names.at( remainder );
} }
}
next+= " " + powers.at( millennium ); next+= " " + powers.at( millennium );
parts.push_back( std::move( next ) ); parts.push_back( std::move( next ) );
} }

View File

@ -24,6 +24,10 @@ static auto init= Alepha::Utility::enroll <=[]
{ "1000283000000", { 1'000'283'000'000 }, { "1000283000000", { 1'000'283'000'000 },
"one trillion two hundred eighty three million" }, "one trillion two hundred eighty three million" },
// I just detected this weird case:
{ "1000100006000500", { 1000100006000500 },
"one quadrillion one hundred billion six million five hundred" },
}; };
-"repl"_test <=[] -"repl"_test <=[]