penguian / glucat

GluCat: Clifford algebra templates
http://glucat.sourceforge.net/
Other
19 stars 6 forks source link

Make promotion monotonic #22

Closed penguian closed 2 years ago

penguian commented 2 years ago

Ensure that numeric_traits<Scalar_T>::promoted::type always has at least as many mantissa bits as Scalar_T, and numeric_traits<Scalar_T>::demoted::type has at most as many mantissa bits as Scalar_T.

See https://en.cppreference.com/w/cpp/language/types . The C++ float and double types are usually based on the IEEE 754 32 bit and 64 bit floating point standards. In contrast, the long double type can be anywhere from 64 bits (as IEEE 754 64 bit floating point) to 128 bits (as IEEE 754 128 bit floating point). The 128 bit format has a precision of 113 bits, but the dd_real format has a precision of only 106 bits.

If long double has the same number of mantissa bits as double, promote as: float -> double -> dd_real -> qd_real, long double -> dd_real, and demote as: qd_real -> dd_real -> double -> float, long double -> float.

If long double has more mantissa bits than dd_real, promote as: float -> double -> dd_real -> long double -> qd_real, and demote as: qd_real -> long double -> dd_real -> double -> float.

Otherwise, continue to promote as: float -> double -> long double -> dd_real -> qd_real, and demote as: qd_real -> dd_real -> long double -> double -> float.

create-issue-branch[bot] commented 2 years ago

Branch issue-22-Make_promotion_monotonic created!

penguian commented 2 years ago

Closed by Pull Request #23