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]

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

PDouble constructor

Parameters
inputvalue to store
precisioncustom precision

◆ PDouble() [2/3]

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

PDouble copy constructor

Parameters
copyPDouble to be copied

◆ PDouble() [3/3]

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

PDouble move constructor

Parameters
tmpPDouble to be moved

◆ ~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()

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

Returns the custom precison

Returns
long double precision

References precision.

◆ getValue()

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

Returns the custom value

Returns
long double value

References value.

◆ operator double()

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

double cast operator

Returns
a copy of value casted to double

◆ operator float()

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

float cast operator

Returns
a copy of value casted to float

◆ operator int()

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

int cast operator

Returns
a copy of value casted to int

◆ operator long double()

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

long double cast operator

Returns
a copy of value casted to long double

◆ operator=() [1/2]

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

◆ operator=() [2/2]

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

◆ setPrecision()

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

Sets a custom precison

Parameters
valuedesired precision

References precision, and value.

Friends And Related Symbol Documentation

◆ operator!=

constexpr 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

◆ operator%

constexpr 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

◆ operator%=

constexpr 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

◆ operator*

constexpr 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

◆ operator*=

constexpr 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

◆ operator+

constexpr 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

◆ operator+=

constexpr 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

◆ operator-

constexpr 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

◆ operator-=

constexpr 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

◆ operator/

constexpr 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

◆ operator/=

constexpr 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

◆ operator<

constexpr 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

◆ 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

◆ operator<=

constexpr 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

◆ operator==

constexpr 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

◆ operator>

constexpr 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

◆ operator>=

constexpr 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

◆ 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

Member Data Documentation

◆ precision

long double woss::PDouble::precision
protected

stored precision

Referenced by getPrecision(), and setPrecision().

◆ value

long double woss::PDouble::value
protected

stored value

Referenced by getValue(), and setPrecision().


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