libnumerixpp  0.1.3
A Powerful C++ Library for High-Performance Numerical Computing
computerscience Namespace Reference

Basic Computer science utils. More...

Functions

auto convert_decimal_to_binary (int decimal) -> std::string
 convert decimal to binary More...
 
auto convert_binary_to_decimal (std::string &binary) -> int
 convert binary to decimal More...
 
auto convert_decimal_to_hexadecimal (int decimal) -> std::string
 convert decimal to hexadecimal More...
 
auto convert_hexadecimal_to_decimal (std::string &hexadecimal) -> int
 convert hexadecimal to decimal More...
 
auto convert_binary_to_hexadecimal (std::string &binary) -> std::string
 convert binary to hexadecimal More...
 
auto convert_hexadecimal_to_binary (std::string &hexadecimal) -> std::string
 
auto humanize_bytes_size (long long bytes, const std::string &suffix="B") -> std::string
 Scale bytes to its proper format. More...
 
auto convert_hexadecimal_to_binary (std::string hexadecimal) -> std::string
 convert hexadecimal to binary More...
 

Detailed Description

Basic Computer science utils.

#include <iostream>
#include <string>
#include "libnumerixpp/core/common.hpp"
#include "libnumerixpp/libnumerixpp.hpp"
auto main() -> int {
println("LIBNUMERIXPP");
int const decimal_number = 777;
std::string binary_number = computerscience::convert_decimal_to_binary(decimal_number);
int const decimal_number2 = computerscience::convert_binary_to_decimal(binary_number);
std::string hexadecimal_number =
int const decimal_number3 = computerscience::convert_hexadecimal_to_decimal(hexadecimal_number);
std::string const hexadecimal_number2 =
std::string const binary_number2 =
computerscience::convert_hexadecimal_to_binary(hexadecimal_number);
long long const bytes = 1024 * 1024;
std::cout << "Convert decimal " << decimal_number << " to binary: " << binary_number << '\n';
std::cout << "Convert binary " << binary_number << " to decimal: " << decimal_number2 << '\n';
std::cout << "Convert decimal " << decimal_number << " to hexadecimal: " << hexadecimal_number
<< '\n';
std::cout << "Convert hexadecimal " << hexadecimal_number << " to decimal: " << decimal_number3
<< '\n';
std::cout << "Convert binary " << binary_number << " to hexadecimal: " << hexadecimal_number2
<< '\n';
std::cout << "Convert hexadecimal " << hexadecimal_number << " to binary: " << binary_number2
<< '\n';
std::cout << "Convert " << bytes << ": " << computerscience::humanize_bytes_size(bytes) << '\n';
return 0;
}
void credits()
print credits
Definition: common.cpp:8
Core utils for computer science.
auto humanize_bytes_size(long long bytes, const std::string &suffix="B") -> std::string
Scale bytes to its proper format.
Definition: core.cpp:76
auto convert_binary_to_hexadecimal(std::string &binary) -> std::string
convert binary to hexadecimal
Definition: core.cpp:62
auto convert_hexadecimal_to_decimal(std::string &hexadecimal) -> int
convert hexadecimal to decimal
Definition: core.cpp:51
auto convert_decimal_to_hexadecimal(int decimal) -> std::string
convert decimal to hexadecimal
Definition: core.cpp:39
auto convert_decimal_to_binary(int decimal) -> std::string
convert decimal to binary
Definition: core.cpp:14
auto convert_binary_to_decimal(std::string &binary) -> int
convert binary to decimal
Definition: core.cpp:29

Function Documentation

◆ convert_binary_to_decimal()

auto computerscience::convert_binary_to_decimal ( std::string &  binary) -> int

convert binary to decimal

Parameters
binaryThe binary
Returns
decimal integer

◆ convert_binary_to_hexadecimal()

auto computerscience::convert_binary_to_hexadecimal ( std::string &  binary) -> std::string

convert binary to hexadecimal

Parameters
binaryThe binary
Returns
hexadecimal number string

◆ convert_decimal_to_binary()

auto computerscience::convert_decimal_to_binary ( int  decimal) -> std::string

convert decimal to binary

Parameters
[in]decimalThe decimal
Returns
binary number string

◆ convert_decimal_to_hexadecimal()

auto computerscience::convert_decimal_to_hexadecimal ( int  decimal) -> std::string

convert decimal to hexadecimal

Parameters
[in]decimalThe decimal
Returns
hexadecimal number string

◆ convert_hexadecimal_to_binary()

auto computerscience::convert_hexadecimal_to_binary ( std::string  hexadecimal) -> std::string

convert hexadecimal to binary

Parameters
[in]hexadecimalThe hexadecimal
Returns
binary number string

◆ convert_hexadecimal_to_decimal()

auto computerscience::convert_hexadecimal_to_decimal ( std::string &  hexadecimal) -> int

convert hexadecimal to decimal

Parameters
hexadecimalThe hexadecimal
Returns
decimal integer

◆ humanize_bytes_size()

auto computerscience::humanize_bytes_size ( long long  bytes,
const std::string &  suffix = "B" 
) -> std::string

Scale bytes to its proper format.

Parameters
[in]bytesThe bytes
[in]suffixThe suffix
Returns
humanized size