Leonardus
Loading...
Searching...
No Matches
Namespaces | Functions
adapter128.h File Reference

Adapters for 128 bit versions of standard functions. More...

#include <string>
#include <gmp.h>
+ Include dependency graph for adapter128.h:
+ This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Namespaces

namespace  adapter128
 Collection of adapters for 128 bit data types.
 

Functions

std::string __int128_to_string (__int128 p_z)
 We need an adapter function, because __int128 isn't supported by std::to_string().
 
std::string __float128_to_string (__float128 p_float, size_t p_precision)
 We need an adapter function, because __float128 isn't supported by std::to_string().
 
__int128 string_to___int128 (const std::string &p_s)
 We need an adapter function, because __int128 isn't supported by the standard library.
 
__float128 string_to___float128 (const std::string &p_s)
 We need an adapter function, because __float128 isn't supported by the standard library.
 
bool mpz_t_to___int128 (__int128 &p_dst, 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.
 
void __float128_to_mpf_t (mpf_t p_dst, __float128 p_f128)
 Converts a __float128 to a mpf_t.
 
__float128 adapter128::ceil (__float128 p_r)
 __float128 overload of ceil().
 
__float128 adapter128::floor (__float128 p_r)
 __float128 overload of floor().
 
__float128 adapter128::trunc (__float128 p_r)
 __float128 overload of trunc().
 
__float128 adapter128::cos (__float128 p_angle)
 __float128 overload of cos().
 
__float128 adapter128::sin (__float128 p_angle)
 __float128 overload of sin().
 
__float128 adapter128::sqrt (__float128 p_r)
 __float128 overload of sqrt().
 
__float128 adapter128::atan2 (__float128 p_num, __float128 p_den)
 __float128 overload of atan2().
 
__float128 adapter128::asin (__float128 p_ratio)
 __float128 overload of asin().
 
__float128 adapter128::acos (__float128 p_ratio)
 __float128 overload of acos().
 
__float128 adapter128::pow (__float128 p_base, __float128 p_exp)
 __float128 overload of pow().
 
__float128 adapter128::rint (__float128 p_num)
 __float128 overload of rint().
 
__float128 adapter128::log (__float128 p_num)
 __float128 overload of log().
 
__float128 adapter128::log10 (__float128 p_num)
 __float128 overload of log10().
 

Detailed Description

Adapters for 128 bit versions of standard functions.

Function Documentation

◆ __float128_to_mpf_t()

void __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.

◆ __float128_to_string()

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

We need an adapter function, because __float128 isn't supported by std::to_string().

Implementation with GNU quadmath.

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

◆ __int128_to_mpz_t()

void __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()

std::string __int128_to_string ( __int128  p_z)

We need an adapter function, because __int128 isn't supported by std::to_string().

Parameters
[in]p_zWe need a representation for this integer.
Returns
std::string ... The string-representation of p_z.

◆ mpz_t_to___int128()

bool mpz_t_to___int128 ( __int128 &  p_dst,
const mpz_t  p_src 
)

Converts a mpz_t into an __int128.

Parameters
[out]p_dstThe destination __int128.
[in]p_srcThe source mpz_t.
Returns
bool ... true, if mpz_t fits into 128 bit integer, false otherwise.

◆ string_to___float128()

__float128 string_to___float128 ( const std::string &  p_s)

We need an adapter function, because __float128 isn't supported by the standard library.

Implemented with GNU quadmath. We accept loosing unsignificant digits during conversion.

Parameters
[in]p_sContains a string representation.
Returns
__float128 ... The float.

◆ string_to___int128()

__int128 string_to___int128 ( const std::string &  p_s)

We need an adapter function, because __int128 isn't 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.