Data Update

This commit is contained in:
Ingy döt Net 2023-07-09 17:42:30 -04:00
parent 015c2add84
commit e50b5c3114
206 changed files with 6337 additions and 523 deletions

View file

@ -1,21 +1,22 @@
#include <cstdint>
#include <iostream>
#include <iomanip>
#include <vector>
#include <bitset>
std::string to_hex(int32_t number) {
std::string to_hex(const int32_t number) {
std::stringstream stream;
stream << std::setfill('0') << std::setw(8) << std::hex << number;
return stream.str();
}
std::string to_binary(int32_t number) {
std::string to_binary(const int32_t number) {
std::stringstream stream;
stream << std::bitset<16>(number);
return stream.str();
}
int32_t twos_complement(int32_t number) {
int32_t twos_complement(const int32_t number) {
return ~number + 1;
}
@ -34,7 +35,7 @@ int main() {
std::cout << std::setw(6) << "-----------" << std::setw(12) << "--------"
<< std::setw(20) << "----------------" << std::setw(20) << "----------------" << std::endl;
for ( int32_t example : examples ) {
for ( const int32_t& example : examples ) {
std::cout << std::setw(6) << example << std::setw(17) << to_upper_case(to_hex(example))
<< std::setw(20) << to_binary(example) << std::setw(13) << twos_complement(example) << std::endl;
}