_e: print large demical representations correctly

This commit is contained in:
Dr-Carlos 2022-12-22 09:58:52 +11:00
parent 5a3de5aa17
commit f16ecc370c
1 changed files with 5 additions and 4 deletions

View File

@ -49,14 +49,15 @@ static _e_args parse_e(Session &session, Parser &parser)
void _e(Session &, std::string, std::vector<long> const &values)
{
for(long value: values) {
long print_val = labs(value);
/* Hexa format */
int length = (labs(value) <= (1ll << 32) ? 8 : 16) + 2 + (value < 0);
int length = (print_val <= (1ll << 32) ? 8 : 16) + 2 + (value < 0);
std::string format = fmt::format("{{:#0{}x}}", length);
fmt::print(format, value);
long a = abs(value);
if(a <= 100 || a % 100 <= 1 || a % 100 >= 99)
fmt::print(" = {}", a);
if(print_val <= 100 || print_val % 100 <= 1 || print_val % 100 >= 99)
fmt::print(" = {}", print_val);
fmt::print("\n");
}