MCPcopy Index your code
hub / github.com/python/cpython / compare_signal

Method compare_signal

Lib/_pydecimal.py:4204–4237  ·  view source on GitHub ↗

Compares the values of the two operands numerically. It's pretty much like compare(), but all NaNs signal, with signaling NaNs taking precedence over quiet NaNs. >>> c = ExtendedContext >>> c.compare_signal(Decimal('2.1'), Decimal('3')) Decimal('-1')

(self, a, b)

Source from the content-addressed store, hash-verified

4202 return a.compare(b, context=self)
4203
4204 def compare_signal(self, a, b):
4205 """Compares the values of the two operands numerically.
4206
4207 It's pretty much like compare(), but all NaNs signal, with signaling
4208 NaNs taking precedence over quiet NaNs.
4209
4210 >>> c = ExtendedContext
4211 >>> c.compare_signal(Decimal('2.1'), Decimal('3'))
4212 Decimal('-1')
4213 >>> c.compare_signal(Decimal('2.1'), Decimal('2.1'))
4214 Decimal('0')
4215 >>> c.flags[InvalidOperation] = 0
4216 >>> print(c.flags[InvalidOperation])
4217 0
4218 >>> c.compare_signal(Decimal('NaN'), Decimal('2.1'))
4219 Decimal('NaN')
4220 >>> print(c.flags[InvalidOperation])
4221 1
4222 >>> c.flags[InvalidOperation] = 0
4223 >>> print(c.flags[InvalidOperation])
4224 0
4225 >>> c.compare_signal(Decimal('sNaN'), Decimal('2.1'))
4226 Decimal('NaN')
4227 >>> print(c.flags[InvalidOperation])
4228 1
4229 >>> c.compare_signal(-1, 2)
4230 Decimal('-1')
4231 >>> c.compare_signal(Decimal(-1), 2)
4232 Decimal('-1')
4233 >>> c.compare_signal(-1, Decimal(2))
4234 Decimal('-1')
4235 """
4236 a = _convert_other(a, raiseit=True)
4237 return a.compare_signal(b, context=self)
4238
4239 def compare_total(self, a, b):
4240 """Compares two operands using their abstract representation.

Callers 1

test_compare_signalMethod · 0.95

Calls 2

_convert_otherFunction · 0.85
compare_signalMethod · 0.45

Tested by 1

test_compare_signalMethod · 0.76