@@ -464,12 +464,7 @@ constexpr auto issignaling(decimal32_fast val) noexcept -> bool
464464
465465constexpr auto isnormal (decimal32_fast val) noexcept -> bool
466466{
467- if (val.exponent_ <= static_cast <std::uint8_t >(detail::precision_v<decimal32> - 1 ))
468- {
469- return false ;
470- }
471-
472- return (val.significand_ != 0 ) && isfinite (val);
467+ return (val.significand_ != 0 ) && isfinite (val) && (val.exponent_ > static_cast <std::uint8_t >(detail::precision_v<decimal32> - 1 ));
473468}
474469
475470constexpr auto isfinite (decimal32_fast val) noexcept -> bool
@@ -479,21 +474,24 @@ constexpr auto isfinite(decimal32_fast val) noexcept -> bool
479474
480475constexpr auto operator ==(decimal32_fast lhs, decimal32_fast rhs) noexcept -> bool
481476{
482- #ifndef BOOST_DECIMAL_FAST_MATH
483- if (isnan (lhs) || isnan (rhs))
484- {
485- return false ;
486- }
487- #endif
488-
489- return (lhs.sign_ == rhs.sign_ ) &
490- (lhs.exponent_ == rhs.exponent_ ) &
477+ return
478+ #ifndef BOOST_DECIMAL_FAST_MATH
479+ !isnan (lhs) && !isnan (rhs) &&
480+ #endif
481+ (lhs.sign_ == rhs.sign_ ) &&
482+ (lhs.exponent_ == rhs.exponent_ ) &&
491483 (lhs.significand_ == rhs.significand_ );
492484}
493485
494486constexpr auto operator !=(decimal32_fast lhs, decimal32_fast rhs) noexcept -> bool
495487{
496- return !(lhs == rhs);
488+ return
489+ #ifndef BOOST_DECIMAL_FAST_MATH
490+ isnan (lhs) || isnan (rhs) ||
491+ #endif
492+ (lhs.sign_ != rhs.sign_ ) ||
493+ (lhs.exponent_ != rhs.exponent_ ) ||
494+ (lhs.significand_ != rhs.significand_ );
497495}
498496
499497constexpr auto operator <(decimal32_fast lhs, decimal32_fast rhs) noexcept -> bool
@@ -521,42 +519,37 @@ constexpr auto operator<(decimal32_fast lhs, decimal32_fast rhs) noexcept -> boo
521519 }
522520 #endif
523521
524- if (lhs.significand_ == 0 || rhs.significand_ == 0 )
525- {
526- if (lhs.significand_ == 0 && rhs.significand_ == 0 )
527- {
528- #ifndef BOOST_DECIMAL_FAST_MATH
529- return lhs.sign_ && !rhs.sign_ ;
530- #else
531- return false ;
532- #endif
533- }
534- return lhs.significand_ == 0 ? !rhs.sign_ : lhs.sign_ ;
535- }
536-
537- if (lhs.sign_ != rhs.sign_ )
538- {
539- return lhs.sign_ ;
540- }
541-
542- if (lhs.exponent_ != rhs.exponent_ )
543- {
544- return lhs.sign_ ? lhs.exponent_ > rhs.exponent_ : lhs.exponent_ < rhs.exponent_ ;
545- }
546-
547- return lhs.sign_ ? lhs.significand_ > rhs.significand_ : lhs.significand_ < rhs.significand_ ;
522+ return fast_type_less_parts_impl (lhs.significand_ , lhs.biased_exponent (), lhs.sign_ ,
523+ rhs.significand_ , rhs.biased_exponent (), rhs.sign_ );
548524}
549525
550526constexpr auto operator <=(decimal32_fast lhs, decimal32_fast rhs) noexcept -> bool
551527{
552528 #ifndef BOOST_DECIMAL_FAST_MATH
553- if (isnan (lhs) || isnan (rhs))
529+ if (! isfinite (lhs) || ! isfinite (rhs))
554530 {
555- return false ;
531+ if (isnan (lhs) || isnan (rhs) ||
532+ (!lhs.isneg () && rhs.isneg ()))
533+ {
534+ return false ;
535+ }
536+ else if (lhs.isneg () && !rhs.isneg ())
537+ {
538+ return true ;
539+ }
540+ else if (isfinite (lhs) && isinf (rhs))
541+ {
542+ return !signbit (rhs);
543+ }
544+ else if (isinf (lhs) && isfinite (rhs))
545+ {
546+ return signbit (rhs);
547+ }
556548 }
557549 #endif
558550
559- return !(rhs < lhs);
551+ return !fast_type_less_parts_impl (rhs.significand_ , rhs.biased_exponent (), rhs.sign_ ,
552+ lhs.significand_ , lhs.biased_exponent (), lhs.sign_ );
560553}
561554
562555constexpr auto operator >(decimal32_fast lhs, decimal32_fast rhs) noexcept -> bool
@@ -567,13 +560,29 @@ constexpr auto operator>(decimal32_fast lhs, decimal32_fast rhs) noexcept -> boo
567560constexpr auto operator >=(decimal32_fast lhs, decimal32_fast rhs) noexcept -> bool
568561{
569562 #ifndef BOOST_DECIMAL_FAST_MATH
570- if (isnan (lhs) || isnan (rhs))
563+ if (! isfinite (lhs) || ! isfinite (rhs))
571564 {
572- return false ;
565+ if (isnan (lhs) || isnan (rhs))
566+ {
567+ return false ;
568+ }
569+ else if (lhs.isneg () && !rhs.isneg ())
570+ {
571+ return false ;
572+ }
573+ else if (isfinite (lhs) && isinf (rhs))
574+ {
575+ return signbit (rhs);
576+ }
577+ else if (isinf (lhs) && isfinite (rhs))
578+ {
579+ return !signbit (lhs);
580+ }
573581 }
574582 #endif
575583
576- return !(lhs < rhs);
584+ return !fast_type_less_parts_impl (lhs.significand_ , lhs.biased_exponent (), lhs.sign_ ,
585+ rhs.significand_ , rhs.biased_exponent (), rhs.sign_ );
577586}
578587
579588template <typename Integer>
0 commit comments