| 793 | } |
| 794 | |
| 795 | QString SymbolTreeDisplayOptions::signedIntegerToString(s64 value, s32 size_bits) const |
| 796 | { |
| 797 | // For bases other than decimal, the user most likely just wants to view the |
| 798 | // underlying representation, so we want to display it as unsigned. |
| 799 | if (m_integer_base != 10) |
| 800 | { |
| 801 | // Truncate sign extended bits. |
| 802 | u64 mask = (static_cast<u64>(1) << size_bits) - 1; |
| 803 | return unsignedIntegerToString(static_cast<u64>(value) & mask, size_bits); |
| 804 | } |
| 805 | |
| 806 | int field_width = 0; |
| 807 | if (m_show_leading_zeroes) |
| 808 | { |
| 809 | field_width = static_cast<int>(ceilf(size_bits / log2f(m_integer_base))); |
| 810 | |
| 811 | // An extra character is needed for the minus sign. |
| 812 | if (value < 0) |
| 813 | field_width++; |
| 814 | } |
| 815 | |
| 816 | return QStringLiteral("%1").arg(value, field_width, m_integer_base, QLatin1Char('0')); |
| 817 | } |
no test coverage detected