Leonardus
Loading...
Searching...
No Matches
Functions
conversion Namespace Reference

Collection of conversion functions. More...

Functions

std::string __int128_to_string (__int128 p_z)
 Converts an __int128 to its string representation.
 
std::string __float128_to_string (__float128 p_float, size_t p_precision)
 Converts a __float128 to its string representation.
 
__int128 string_to___int128 (const std::string &p_s)
 Converts a string to an __int128 value.
 
__float128 string_to___float128 (const std::string &p_s)
 Converts a string to a __float128 value.
 
std::pair< bool, __float128 > mpz_t_to___float128 (const mpz_t p_src)
 Converts a mpz_t into a __float128.
 
std::pair< bool, __int128 > mpz_t_to___int128 (const mpz_t p_src)
 Converts a mpz_t into an __int128.
 
void __int128_to_mpz_t (mpz_t p_dst, __int128 p_src)
 Converts an __int128 into a mpz_t.
 
bool __float128_to_mpf_t (mpf_t p_dst, __float128 p_f128)
 Converts a __float128 to a mpf_t.
 

Detailed Description

Collection of conversion functions.

Function Documentation

◆ __float128_to_mpf_t()

bool conversion::__float128_to_mpf_t ( mpf_t  p_dst,
__float128  p_f128 
)

Converts a __float128 to a mpf_t.

Note: GMP doesn't support 128 Bit floats directly.

Parameters
[out]p_dstThe destination mpf_t.
[in]p_f128The source __float128.
Returns
bool ... false for an internal error, otherwise true.

◆ __float128_to_string()

string conversion::__float128_to_string ( __float128  p_float,
size_t  p_precision 
)

Converts a __float128 to its string representation.

This adapter is required because __float128 is not supported by std::to_string(). Implementation uses GNU quadmath.

Parameters
[in]p_floatThe __float128 to convert.
[in]p_precisionThe number of decimal digits to include.
Returns
std::string ... The string representation of p_float.

◆ __int128_to_mpz_t()

void conversion::__int128_to_mpz_t ( mpz_t  p_dst,
__int128  p_src 
)

Converts an __int128 into a mpz_t.

Parameters
[out]p_dstThe destination mpz_t.
[in]p_srcThe source __int128.

◆ __int128_to_string()

string conversion::__int128_to_string ( __int128  p_z)

Converts an __int128 to its string representation.

This adapter is required because __int128 is not supported by std::to_string().

Parameters
[in]p_zThe __int128 value to convert.
Returns
std::string ... The string representation of p_z.

◆ mpz_t_to___float128()

std::pair< bool, __float128 > conversion::mpz_t_to___float128 ( const mpz_t  p_src)

Converts a mpz_t into a __float128.

Least significant digits are discarded if they do not fit into the __float128.

Parameters
[in]p_srcThe source mpz_t.
Returns
std::pair<bool,__float128> ...
- true, if p_src can be represented or approximated by a __float128, false otherwise.
- The destination __float128.

◆ mpz_t_to___int128()

std::pair< bool, __int128 > conversion::mpz_t_to___int128 ( const mpz_t  p_src)

Converts a mpz_t into an __int128.

Parameters
[in]p_srcThe source mpz_t.
Returns
std::pair<bool,__int128> ...
- true, if p_src fits into __int128, false otherwise.
- The destination __int128.

◆ string_to___float128()

__float128 conversion::string_to___float128 ( const std::string &  p_s)

Converts a string to a __float128 value.

This adapter is required because __float128 is not supported by the standard library. Implemented using GNU quadmath. Insignificant digits may be discarded during conversion.

Precondition
p_s must be a syntactically valid float and must not cause an overflow in __float128.
Parameters
[in]p_sThe string representation of the float.
Returns
__float128 ... The converted float.

◆ string_to___int128()

__int128 conversion::string_to___int128 ( const std::string &  p_s)

Converts a string to an __int128 value.

This adapter is required because __int128 is not supported by the standard library.

Precondition
p_s format is: [-][digit]+
MIN_INT <= integer interpretation <= MAX_INT
Parameters
[in]p_sThe string to convert.
Returns
__int128 ... The integer interpretation of p_s.