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

Avoid swaps in operators+ #676

Closed mborland closed 2 days ago

mborland commented 1 week ago

Right now we do a swap if necessary so that LHS is always greater than RHS. Can this be skipped and we use references in the xx_add_impl like in xx_sub_impl?

mborland commented 1 week ago

decimal32 shows a couple percent speedup by implementing this. I expect that as the swap operation gets more expensive we should continue to see better increases. The new impl also has 2 fewer branches.