World Ocean Simulation System (WOSS) library
woss::PDouble Class Reference

Custom precision long double class. More...

#include <custom-precision-double.h>

Collaboration diagram for woss::PDouble:
Collaboration graph

Public Member Functions

constexpr PDouble (const long double input=0.0, const long double precision=PDOUBLE_DEFAULT_PRECISION) noexcept
 PDouble (const PDouble &copy) noexcept=default
 PDouble (PDouble &&tmp) noexcept=default
 ~PDouble () noexcept=default
constexpr void setPrecision (double value) noexcept
constexpr long double getPrecision () const noexcept
constexpr long double getValue () const noexcept
constexpr PDoubleoperator= (const PDouble &copy) noexcept=default
constexpr PDoubleoperator= (PDouble &&tmp) noexcept=default
constexpr operator int () const
constexpr operator float () const
constexpr operator double () const
constexpr operator long double () const

Protected Attributes

long double value
long double precision

Friends

constexpr PDouble operator+ (const PDouble &left, const PDouble &right)
constexpr PDouble operator- (const PDouble &left, const PDouble &right)
constexpr PDouble operator/ (const PDouble &left, const PDouble &right)
constexpr PDouble operator* (const PDouble &left, const PDouble &right)
constexpr PDouble operator% (const PDouble &left, const PDouble &right)
constexpr PDoubleoperator+= (PDouble &left, const PDouble &right)
constexpr PDoubleoperator-= (PDouble &left, const PDouble &right)
constexpr PDoubleoperator/= (PDouble &left, const PDouble &right)
constexpr PDoubleoperator*= (PDouble &left, const PDouble &right)
constexpr PDoubleoperator%= (PDouble &left, const PDouble &right)
constexpr bool operator== (const PDouble &left, const PDouble &right)
constexpr bool operator!= (const PDouble &left, const PDouble &right)
constexpr bool operator> (const PDouble &left, const PDouble &right)
constexpr bool operator< (const PDouble &left, const PDouble &right)
constexpr bool operator>= (const PDouble &left, const PDouble &right)
constexpr bool operator<= (const PDouble &left, const PDouble &right)
std::ostream & operator<< (std::ostream &os, const PDouble &instance)
std::istream & operator>> (std::istream &is, PDouble &instance)

Detailed Description

Custom precision long double class.

The PDouble class stores a long double value and a long double precision for arithmetic computation and comparison purposes.

Constructor & Destructor Documentation

◆ PDouble() [1/3]

woss::PDouble::PDouble ( const long double input = 0.0,
const long double precision = PDOUBLE_DEFAULT_PRECISION )
inlineconstexprnoexcept

◆ PDouble() [2/3]

woss::PDouble::PDouble ( const PDouble & copy)
defaultnoexcept

PDouble copy constructor

Parameters
copyPDouble to be copied

References PDouble().

Here is the call graph for this function:

◆ PDouble() [3/3]

woss::PDouble::PDouble ( PDouble && tmp)
defaultnoexcept

PDouble move constructor

Parameters
tmpPDouble to be moved

References PDouble().

Here is the call graph for this function:

◆ ~PDouble()

woss::PDouble::~PDouble ( )
defaultnoexcept

PDouble destructor. It is not virtual, since this class is not meant to be inherited from

Member Function Documentation

◆ getPrecision()

long double woss::PDouble::getPrecision ( ) const
inlineconstexprnoexcept

Returns the custom precison

Returns
long double precision

References precision.

Referenced by WossUnitTest::testPDouble().

◆ getValue()

long double woss::PDouble::getValue ( ) const
inlineconstexprnoexcept

Returns the custom value

Returns
long double value

References value.

Referenced by WossUnitTest::testPDouble().

◆ operator double()

woss::PDouble::operator double ( ) const
inlineconstexpr

double cast operator

Returns
a copy of value casted to double

References value.

◆ operator float()

woss::PDouble::operator float ( ) const
inlineconstexpr

float cast operator

Returns
a copy of value casted to float

References value.

◆ operator int()

woss::PDouble::operator int ( ) const
inlineconstexpr

int cast operator

Returns
a copy of value casted to int

References value.

◆ operator long double()

woss::PDouble::operator long double ( ) const
inlineconstexpr

long double cast operator

Returns
a copy of value casted to long double

References value.

◆ operator=() [1/2]

PDouble & woss::PDouble::operator= ( const PDouble & copy)
constexprdefaultnoexcept

References PDouble().

Here is the call graph for this function:

◆ operator=() [2/2]

PDouble & woss::PDouble::operator= ( PDouble && tmp)
constexprdefaultnoexcept

References PDouble().

Here is the call graph for this function:

◆ setPrecision()

void woss::PDouble::setPrecision ( double value)
inlineconstexprnoexcept

Sets a custom precison

Parameters
valuedesired precision

References precision, setPrecision(), and value.

Referenced by setPrecision().

Here is the call graph for this function:

◆ operator!=

bool operator!= ( const PDouble & left,
const PDouble & right )
friend

Inequality operator

Parameters
leftleft operand const reference
rightright operand const reference
Returns
true if left != right, false otherwise

References PDouble(), precision, and value.

◆ operator%

PDouble operator% ( const PDouble & left,
const PDouble & right )
friend

Modulo operator

Parameters
leftleft operand const reference
rightright operand const reference
Returns
a new const instance holding the operation result

References PDouble(), precision, and value.

◆ operator%=

PDouble & operator%= ( PDouble & left,
const PDouble & right )
friend

Compound assignment modulo operator

Parameters
leftleft operand reference
rightright operand const reference
Returns
left reference after the operation

References PDouble(), and value.

◆ operator*

PDouble operator* ( const PDouble & left,
const PDouble & right )
friend

Multiplication operator

Parameters
leftleft operand const reference
rightright operand const reference
Returns
a new const instance holding the operation result

References PDouble(), precision, and value.

◆ operator*=

PDouble & operator*= ( PDouble & left,
const PDouble & right )
friend

Compound assignment multiplication operator

Parameters
leftleft operand reference
rightright operand const reference
Returns
left reference after the operation

References PDouble(), and value.

◆ operator+

PDouble operator+ ( const PDouble & left,
const PDouble & right )
friend

Sum operator

Parameters
leftleft operand const reference
rightright operand const reference
Returns
a new const instance holding the operation result

References PDouble(), precision, and value.

◆ operator+=

PDouble & operator+= ( PDouble & left,
const PDouble & right )
friend

Compound assignment sum operator

Parameters
leftleft operand reference
rightright operand const reference
Returns
left reference after the operation

References PDouble(), and value.

◆ operator-

PDouble operator- ( const PDouble & left,
const PDouble & right )
friend

Subtraction operator

Parameters
leftleft operand const reference
rightright operand const reference
Returns
a new const instance holding the operation result

References PDouble(), precision, and value.

◆ operator-=

PDouble & operator-= ( PDouble & left,
const PDouble & right )
friend

Compound assignment subtraction operator

Parameters
leftleft operand reference
rightright operand const reference
Returns
left reference after the operation

References PDouble(), and value.

◆ operator/

PDouble operator/ ( const PDouble & left,
const PDouble & right )
friend

Division operator

Parameters
leftleft operand const reference
rightright operand const reference
Returns
a new const instance holding the operation result

References PDouble(), precision, and value.

◆ operator/=

PDouble & operator/= ( PDouble & left,
const PDouble & right )
friend

Compound assignment division operator

Parameters
leftleft operand reference
rightright operand const reference
Returns
left reference after the operation

References PDouble(), and value.

◆ operator<

bool operator< ( const PDouble & left,
const PDouble & right )
friend

Less than operator

Parameters
leftleft operand const reference
rightright operand const reference
Returns
true if left < right, false otherwise

References PDouble(), and value.

◆ operator<<

std::ostream & operator<< ( std::ostream & os,
const PDouble & instance )
friend

<< operator

Parameters
osleft operand ostream reference
instanceright operand const PDouble reference
Returns
os reference after the operation

References PDouble(), and value.

◆ operator<=

bool operator<= ( const PDouble & left,
const PDouble & right )
friend

Less than or equal to operator

Parameters
leftleft operand const reference
rightright operand const reference
Returns
true if left <= right, false otherwise

References PDouble(), and value.

◆ operator==

bool operator== ( const PDouble & left,
const PDouble & right )
friend

Equality operator

Parameters
leftleft operand const reference
rightright operand const reference
Returns
true if left == right, false otherwise

References PDouble(), precision, and value.

◆ operator>

bool operator> ( const PDouble & left,
const PDouble & right )
friend

Greater than operator

Parameters
leftleft operand const reference
rightright operand const reference
Returns
true if left > right, false otherwise

References PDouble(), and value.

◆ operator>=

bool operator>= ( const PDouble & left,
const PDouble & right )
friend

Greater than or equal to operator

Parameters
leftleft operand const reference
rightright operand const reference
Returns
true if left >= right, false otherwise

References PDouble(), and value.

◆ operator>>

std::istream & operator>> ( std::istream & is,
PDouble & instance )
friend

operator

Parameters
isleft operand istream reference
instanceright operand PDouble reference. It will take the value provided by left with default precision
Returns
is reference after the operation

References PDouble(), and value.

Member Data Documentation

◆ precision

long double woss::PDouble::precision
protected

◆ value


The documentation for this class was generated from the following file: