MCPcopy Create free account
hub / github.com/numpy/numpy / Less

Method Less

numpy/core/src/common/half.hpp:172–188  ·  view source on GitHub ↗

@name Comparison with no guarantee of NaN behavior @{

Source from the content-addressed store, hash-verified

170 /// @name Comparison with no guarantee of NaN behavior
171 /// @{
172 constexpr bool Less(Half r) const
173 {
174 uint_fast16_t a = static_cast<uint_fast16_t>(bits_),
175 b = static_cast<uint_fast16_t>(r.bits_);
176 bool sign_a = (a & 0x8000u) == 0x8000u;
177 bool sign_b = (b & 0x8000u) == 0x8000u;
178 // if both `a` and `b` have same sign
179 // Test if `a` > `b` when `a` has the sign
180 // or `a` < `b` when is not.
181 // And make sure they are not equal to each other
182 // in case of both are equal to +-0
183 // else
184 // Test if `a` has the sign.
185 // and `a` != -0.0 and `b` != 0.0
186 return (sign_a == sign_b) ? (sign_a ^ (a < b)) && (a != b)
187 : sign_a && ((a | b) != 0x8000u);
188 }
189 constexpr bool LessEqual(Half r) const
190 {
191 uint_fast16_t a = static_cast<uint_fast16_t>(bits_),

Callers 1

npy_half_lt_nonanFunction · 0.80

Calls

no outgoing calls

Tested by

no test coverage detected