HEKTO
HEKTO

Reputation: 4191

The `CryptoPP::Integer` alignment during output

I'm trying to output values of the CryptoPP::Integer type nicely using manipulators. My small test is below:

#include <iomanip>
#include <iostream>
#include <crypto++/integer.h>

int main()
{
  std::cout << "int, aligned to the right              : " << std::setw(6) << std::right << int(100) << std::endl;
  std::cout << "CryptoPP::Integer, aligned to the right: " << std::setw(6) << std::right << CryptoPP::Integer(100) << std::endl;
  std::cout << "int, aligned to the left               : " << std::setw(6) << std::left << int(100) << std::endl;
  std::cout << "CryptoPP::Integer, aligned to the left : " << std::setw(6) << std::left << CryptoPP::Integer(100) << std::endl;
}

The result looks like this:

int, aligned to the right              :    100
CryptoPP::Integer, aligned to the right:      100.
int, aligned to the left               : 100   
CryptoPP::Integer, aligned to the left : 1     00.

So, the alignment of the CryptoPP::Integer value to the right doesn't work correctly, and the alignment to the left breaks the value into two parts. Also a . in the end?

Is it a known bug? How to deal with it?

(crypto++ version - 5.6.4-8)

UPDATE from 11/4/24. There is exactly same problem in the version 8.6.0.

Upvotes: 1

Views: 71

Answers (0)

Related Questions