cppalliance / decimal

A C++14 implementation of IEEE 754 decimal floating point numbers
https://cppalliance.org/decimal/decimal.html
Boost Software License 1.0
17 stars 1 forks source link

Duplicate operations in basic operations #618

Closed mborland closed 1 week ago

mborland commented 1 month ago

In the division impls we promote the LHS to the next biggest integer type (e.g uint32_t -> uint64_t) and then shrink it back down to return it in a struct that then gets passed ot the decimal constructor: https://github.com/cppalliance/decimal/blob/develop/include/boost/decimal/detail/div_impl.hpp#L80. We can remove all of the shrinking back down steps since the decimal constructor is already designed to handle big integer types. This may or may not apply to dec128 since I don't think the uint256_t case is handled in the constructor since that is only for internal usage.

mborland commented 2 weeks ago

This actually seems to apply to all the basic operations. Adding a task list since dec32 and 64 are trivial but 128 would need extra operators added to uint256_t. Would it be better to just shrink instead of performing additional operations with the uint256_t? Only time will tell.