Printing an `Integer` as hex appends an 'h'

16 views
Skip to first unread message

Addy

unread,
Dec 30, 2020, 9:08:54 PM12/30/20
to Crypto++ Users
If I do this: 

std::uint64_t x = 100;
std::cout << std::hex << x;

The output is: 64

If I instead do this:

CryptoPP::Integer x1 = 100;
std::cout << std::hex << x1;

The output is: 64h

From where is this "h" coming and how do I get rid of it?

Adalid Claure

unread,
Dec 30, 2020, 9:26:00 PM12/30/20
to cryptop...@googlegroups.com
I see it's hard coded in integer.cpp with no way to get rid of it. Guess I'll just strip it off the string value. 

--
You received this message because you are subscribed to "Crypto++ Users". More information about Crypto++ and this group is available at http://www.cryptopp.com and http://groups.google.com/forum/#!forum/cryptopp-users.
---
You received this message because you are subscribed to the Google Groups "Crypto++ Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to cryptopp-user...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/cryptopp-users/6fc6d2ab-ead6-4e03-af75-9bd4053bc1c7n%40googlegroups.com.

Jeffrey Walton

unread,
Jan 2, 2021, 12:01:54 AM1/2/21
to Crypto++ Users List
Yeah, I've never really liked that behavior either. Unfortunately, the
behavior is ingrained in the library. We could not change the default
even if we wanted to. It would break too many programs.

To turn off the suffixes, see
https://www.cryptopp.com/wiki/Integer_Patch#std::showbase_and_Suffixes.

Jeff
Reply all
Reply to author
Forward
0 new messages