numerical-collection-cpp 0.10.0
A collection of algorithms in numerical analysis implemented in C++
Loading...
Searching...
No Matches
num_collect::numbers::custom_float< Radix, Digit, DigitCalc > Class Template Reference

Class of floating numbers in a custom number system with given radix. More...

#include <num_collect/numbers/custom_float.h>

+ Collaboration diagram for num_collect::numbers::custom_float< Radix, Digit, DigitCalc >:

Public Types

using digit_calc_type = DigitCalc
 Type of digits for calculation.
 
using digit_type = Digit
 Type of digits.
 

Public Member Functions

 custom_float ()
 Construct zero.
 
auto at (index_type index) const -> digit_type
 Access a digit with checks.
 
auto highest_ind () const noexcept -> index_type
 Get the index of the highest digit.
 
auto lowest_ind () const noexcept -> index_type
 Get the index of the lowest digits.
 
void move_digits (index_type offset)
 Move digits.
 
auto operator[] (index_type index) -> digit_type &
 Access a digit preparing it if needed.
 
auto operator[] (index_type index) const -> digit_type
 Access a digit without checks.
 
void push_to_highest (digit_type digit)
 Add a digit to the highest end.
 
void push_to_lowest (digit_type digit)
 Add a digit to the lowest end.
 
void resize (index_type lowest, index_type highest)
 Change the range of digits.
 

Static Public Attributes

static constexpr index_type radix = Radix
 Radix of the number system.
 

Private Attributes

util::bidirectional_vector< digit_typedigits_
 Digits.
 

Detailed Description

template<index_type Radix, base::concepts::integral Digit = std::uint8_t, base::concepts::signed_integral DigitCalc = std::int32_t>
class num_collect::numbers::custom_float< Radix, Digit, DigitCalc >

Class of floating numbers in a custom number system with given radix.

Template Parameters
RadixRadix of the number system.
DigitType of digits.
DigitCalcType of digits for calculation.

Definition at line 41 of file custom_float.h.

Member Typedef Documentation

◆ digit_calc_type

template<index_type Radix, base::concepts::integral Digit = std::uint8_t, base::concepts::signed_integral DigitCalc = std::int32_t>
using num_collect::numbers::custom_float< Radix, Digit, DigitCalc >::digit_calc_type = DigitCalc

Type of digits for calculation.

Definition at line 54 of file custom_float.h.

◆ digit_type

template<index_type Radix, base::concepts::integral Digit = std::uint8_t, base::concepts::signed_integral DigitCalc = std::int32_t>
using num_collect::numbers::custom_float< Radix, Digit, DigitCalc >::digit_type = Digit

Type of digits.

Definition at line 51 of file custom_float.h.

Constructor & Destructor Documentation

◆ custom_float()

template<index_type Radix, base::concepts::integral Digit = std::uint8_t, base::concepts::signed_integral DigitCalc = std::int32_t>
num_collect::numbers::custom_float< Radix, Digit, DigitCalc >::custom_float ( )
inline

Construct zero.

Definition at line 59 of file custom_float.h.

Member Function Documentation

◆ at()

template<index_type Radix, base::concepts::integral Digit = std::uint8_t, base::concepts::signed_integral DigitCalc = std::int32_t>
auto num_collect::numbers::custom_float< Radix, Digit, DigitCalc >::at ( index_type index) const -> digit_type
inlinenodiscard

Access a digit with checks.

Parameters
[in]indexIndex.
Returns
Index.

Definition at line 89 of file custom_float.h.

◆ highest_ind()

template<index_type Radix, base::concepts::integral Digit = std::uint8_t, base::concepts::signed_integral DigitCalc = std::int32_t>
auto num_collect::numbers::custom_float< Radix, Digit, DigitCalc >::highest_ind ( ) const -> index_type
inlinenodiscardnoexcept

Get the index of the highest digit.

Returns
Index of the highest digit.

Definition at line 79 of file custom_float.h.

◆ lowest_ind()

template<index_type Radix, base::concepts::integral Digit = std::uint8_t, base::concepts::signed_integral DigitCalc = std::int32_t>
auto num_collect::numbers::custom_float< Radix, Digit, DigitCalc >::lowest_ind ( ) const -> index_type
inlinenodiscardnoexcept

Get the index of the lowest digits.

Returns
Index of lowest digits.

Definition at line 70 of file custom_float.h.

◆ move_digits()

template<index_type Radix, base::concepts::integral Digit = std::uint8_t, base::concepts::signed_integral DigitCalc = std::int32_t>
void num_collect::numbers::custom_float< Radix, Digit, DigitCalc >::move_digits ( index_type offset)
inline

Move digits.

Parameters
[in]offsetOffset from the current places of digits.

Definition at line 136 of file custom_float.h.

◆ operator[]() [1/2]

template<index_type Radix, base::concepts::integral Digit = std::uint8_t, base::concepts::signed_integral DigitCalc = std::int32_t>
auto num_collect::numbers::custom_float< Radix, Digit, DigitCalc >::operator[] ( index_type index) -> digit_type&
inlinenodiscard

Access a digit preparing it if needed.

Warning
Inserted value won't be checked.
Parameters
[in]indexIndex.
Returns
Index.

Definition at line 113 of file custom_float.h.

◆ operator[]() [2/2]

template<index_type Radix, base::concepts::integral Digit = std::uint8_t, base::concepts::signed_integral DigitCalc = std::int32_t>
auto num_collect::numbers::custom_float< Radix, Digit, DigitCalc >::operator[] ( index_type index) const -> digit_type
inlinenodiscard

Access a digit without checks.

Warning
Access to indices out of range causes undefined behaviour.
Parameters
[in]indexIndex.
Returns
Index.

Definition at line 101 of file custom_float.h.

◆ push_to_highest()

template<index_type Radix, base::concepts::integral Digit = std::uint8_t, base::concepts::signed_integral DigitCalc = std::int32_t>
void num_collect::numbers::custom_float< Radix, Digit, DigitCalc >::push_to_highest ( digit_type digit)
inline

Add a digit to the highest end.

Parameters
[in]digitDigit.

Definition at line 129 of file custom_float.h.

◆ push_to_lowest()

template<index_type Radix, base::concepts::integral Digit = std::uint8_t, base::concepts::signed_integral DigitCalc = std::int32_t>
void num_collect::numbers::custom_float< Radix, Digit, DigitCalc >::push_to_lowest ( digit_type digit)
inline

Add a digit to the lowest end.

Parameters
[in]digitDigit.

Definition at line 122 of file custom_float.h.

◆ resize()

template<index_type Radix, base::concepts::integral Digit = std::uint8_t, base::concepts::signed_integral DigitCalc = std::int32_t>
void num_collect::numbers::custom_float< Radix, Digit, DigitCalc >::resize ( index_type lowest,
index_type highest )
inline

Change the range of digits.

Parameters
[in]lowestIndex of lowest digits.
[in]highestIndex of the highest digit.

Definition at line 144 of file custom_float.h.

Member Data Documentation

◆ digits_

template<index_type Radix, base::concepts::integral Digit = std::uint8_t, base::concepts::signed_integral DigitCalc = std::int32_t>
util::bidirectional_vector<digit_type> num_collect::numbers::custom_float< Radix, Digit, DigitCalc >::digits_
private

Digits.

Definition at line 150 of file custom_float.h.

◆ radix

template<index_type Radix, base::concepts::integral Digit = std::uint8_t, base::concepts::signed_integral DigitCalc = std::int32_t>
index_type num_collect::numbers::custom_float< Radix, Digit, DigitCalc >::radix = Radix
staticconstexpr

Radix of the number system.

Definition at line 48 of file custom_float.h.


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