HRCore V1.1.0
A High Resolution Calculation Library
Loading...
Searching...
No Matches
HRCore::Value::Float Class Reference

Float type. More...

#include <Value.hpp>

Inheritance diagram for HRCore::Value::Float:
Inheritance graph
Collaboration diagram for HRCore::Value::Float:
Collaboration graph

Public Member Functions

 Float (Float &&c)
 Reload of move constructor. More...
 
 Float (Integer &&c, int fpos, size_t tpos)
 
 Float (const Float &c)
 Reload of copy constructor. More...
 
 Float (const Integer &c, int fpos=0, size_t tpos=0)
 Copy value of Integer object and convert to a Float object. More...
 
Floatoperator= (Float &&c)
 Move operator. More...
 
Floatoperator= (const Float &c)
 Copy operator. More...
 
Floatoperator= (const double c)
 transform IEEE-754 Floating point value into Float object More...
 
size_t precision ()
 Get current precision of division and input. More...
 
void precision (size_t n)
 Set precision of division and input. More...
 
Float operator+ (const Float &s)
 Reload of operator+. More...
 
Float operator- (const Float &s)
 Reload of operator-. More...
 
Float operator* (const Float &s)
 Reload of operator*. More...
 
Float operator/ (const Integer &s)
 Reload of operator/ (for Integer) More...
 
Float operator/ (const Float &s)
 Reload of operator/ (for Float) More...
 
Integer getInteger ()
 Get Interger section. More...
 
bool operator< (const Float &rhs)
 
bool operator> (const Float &rhs)
 
bool operator== (const Float &rhs)
 
bool operator>= (const Float &rhs)
 
bool operator<= (const Float &rhs)
 
 Integer (Storage::Interface *ptr, bool positive=true, bool autoRelease=false, bool sim=true)
 Construct a new Integer object. More...
 
 Integer (Integer &&c)
 Move a Integer object. More...
 
 Integer (const Integer &c)
 Copy and construct a new Integer object. More...
 
Integer make ()
 Make a new object with same Interface type. More...
 
bool positive () const
 Return the sign of object. More...
 
void positive (bool p)
 Set the sign of object. More...
 

Static Public Member Functions

template<typename T >
static Integer make ()
 Construct a new Integer object using given type of Storage::Interface implement. More...
 

Protected Attributes

int _fpos = 0
 
size_t _tpos = 0
 
size_t _precision = 10
 

Friends

std::istream & operator>> (std::istream &is, Float &rhs)
 Reload of operator>> to support std::cin and other std::istream with Float. More...
 
std::ostream & operator<< (std::ostream &os, Float &rhs)
 Reload of operator<< to support std::cout and other std::ostream with Integer. More...
 

Detailed Description

Float type.

The class is a child of Integer; Somewhat like (IEEE-754)

Note
If some function is not documented, please refer to document of Integer!

Definition at line 648 of file Value.hpp.

Constructor & Destructor Documentation

◆ Float() [1/4]

HRCore::Value::Float::Float ( Float &&  c)
inline

Reload of move constructor.

Definition at line 656 of file Value.hpp.

◆ Float() [2/4]

HRCore::Value::Float::Float ( Integer &&  c,
int  fpos,
size_t  tpos 
)
inline

Definition at line 663 of file Value.hpp.

◆ Float() [3/4]

HRCore::Value::Float::Float ( const Float c)
inline

Reload of copy constructor.

Definition at line 672 of file Value.hpp.

◆ Float() [4/4]

HRCore::Value::Float::Float ( const Integer c,
int  fpos = 0,
size_t  tpos = 0 
)
inline

Copy value of Integer object and convert to a Float object.

Definition at line 680 of file Value.hpp.

Member Function Documentation

◆ getInteger()

Integer HRCore::Value::Float::getInteger ( )
inline

Get Interger section.

Definition at line 791 of file Value.hpp.

◆ Integer() [1/3]

HRCore::Value::Integer::Integer ( const Integer c)
inline

Copy and construct a new Integer object.

Note
The internal data type is decided by parameter c!
Parameters
cPrevious Integer object to be copied.

Definition at line 159 of file Value.hpp.

◆ Integer() [2/3]

HRCore::Value::Integer::Integer ( Integer &&  c)
inline

Move a Integer object.

Parameters
cThe Integer object to be moved

Definition at line 125 of file Value.hpp.

◆ Integer() [3/3]

HRCore::Value::Integer::Integer ( Storage::Interface ptr,
bool  positive = true,
bool  autoRelease = false,
bool  sim = true 
)
inline

Construct a new Integer object.

Parameters
ptrA pointer to a object of a class that implemented Storage::Interface
positiveDecide whether the Integer object is positive or negative
autoReleaseSpecify if the ptr should be release autonomously after deconstruction
simDecide if the data should be simplified first. (Internally)
Exceptions
-1when the ptr is invalid.
Here is an example:
ChainList<8> sto;
Integer a(&sto);
Integer type.
Definition: Value.hpp:27
Note
The Storage::Interface implemented object should NOT be destroyed before destruction of object of this class.
Exceptions
Exception::InvalidArgumentis throw when ptr is nullptr

Definition at line 84 of file Value.hpp.

◆ make() [1/2]

template<typename T >
static Integer HRCore::Value::Integer::make ( )
inlinestatic

Construct a new Integer object using given type of Storage::Interface implement.

Template Parameters
TType of Storage::Interface implement
Returns
Integer New object
Here is a example:
Integer&& it = Integer::make<Storage::LinkedList<8>>();

Definition at line 109 of file Value.hpp.

Here is the caller graph for this function:

◆ make() [2/2]

Integer HRCore::Value::Integer::make ( )
inline

Make a new object with same Interface type.

Definition at line 115 of file Value.hpp.

◆ operator*()

Float HRCore::Value::Float::operator* ( const Float s)
inline

Reload of operator*.

Definition at line 762 of file Value.hpp.

◆ operator+()

Float HRCore::Value::Float::operator+ ( const Float s)
inline

Reload of operator+.

Definition at line 746 of file Value.hpp.

◆ operator-()

Float HRCore::Value::Float::operator- ( const Float s)
inline

Reload of operator-.

Definition at line 754 of file Value.hpp.

◆ operator/() [1/2]

Float HRCore::Value::Float::operator/ ( const Float s)
inline

Reload of operator/ (for Float)

Definition at line 779 of file Value.hpp.

◆ operator/() [2/2]

Float HRCore::Value::Float::operator/ ( const Integer s)
inline

Reload of operator/ (for Integer)

Definition at line 765 of file Value.hpp.

◆ operator<()

bool HRCore::Value::Float::operator< ( const Float rhs)
inline

Definition at line 799 of file Value.hpp.

◆ operator<=()

bool HRCore::Value::Float::operator<= ( const Float rhs)
inline

Definition at line 803 of file Value.hpp.

◆ operator=() [1/3]

Float & HRCore::Value::Float::operator= ( const double  c)
inline

transform IEEE-754 Floating point value into Float object

Definition at line 707 of file Value.hpp.

Here is the call graph for this function:

◆ operator=() [2/3]

Float & HRCore::Value::Float::operator= ( const Float c)
inline

Copy operator.

Definition at line 698 of file Value.hpp.

Here is the call graph for this function:

◆ operator=() [3/3]

Float & HRCore::Value::Float::operator= ( Float &&  c)
inline

Move operator.

Definition at line 688 of file Value.hpp.

Here is the call graph for this function:

◆ operator==()

bool HRCore::Value::Float::operator== ( const Float rhs)
inline

Definition at line 801 of file Value.hpp.

◆ operator>()

bool HRCore::Value::Float::operator> ( const Float rhs)
inline

Definition at line 800 of file Value.hpp.

◆ operator>=()

bool HRCore::Value::Float::operator>= ( const Float rhs)
inline

Definition at line 802 of file Value.hpp.

◆ positive() [1/2]

bool HRCore::Value::Integer::positive ( ) const
inline

Return the sign of object.

Definition at line 380 of file Value.hpp.

◆ positive() [2/2]

void HRCore::Value::Integer::positive ( bool  p)
inline

Set the sign of object.

Parameters
pWhether positive is true or false

Definition at line 386 of file Value.hpp.

◆ precision() [1/2]

size_t HRCore::Value::Float::precision ( )
inline

Get current precision of division and input.

Definition at line 731 of file Value.hpp.

◆ precision() [2/2]

void HRCore::Value::Float::precision ( size_t  n)
inline

Set precision of division and input.

The 'precision' use for input generate and division.

For input generation, the precision is the minimal precision. For division, the precision is the max precision.

To get actual precision, please make sure that both dividend and divider are generated from input with same precision.

Parameters
nThe expected precision

Definition at line 743 of file Value.hpp.

Friends And Related Function Documentation

◆ operator<<

std::ostream & operator<< ( std::ostream &  os,
Float rhs 
)
friend

Reload of operator<< to support std::cout and other std::ostream with Integer.

Note
Only decimal mode is supported.

Definition at line 232 of file Utils.hpp.

◆ operator>>

std::istream & operator>> ( std::istream &  is,
Float rhs 
)
friend

Reload of operator>> to support std::cin and other std::istream with Float.

Note
Only decimal mode is supported.

Definition at line 185 of file Utils.hpp.

Member Data Documentation

◆ _fpos

int HRCore::Value::Float::_fpos = 0
protected

Definition at line 823 of file Value.hpp.

◆ _precision

size_t HRCore::Value::Float::_precision = 10
protected

Definition at line 825 of file Value.hpp.

◆ _tpos

size_t HRCore::Value::Float::_tpos = 0
protected

Definition at line 824 of file Value.hpp.


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