MCPcopy Index your code
hub / github.com/RustPython/RustPython / compare_signal

Method compare_signal

Lib/_pydecimal.py:4201–4234  ·  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

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