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

Method sqrt

Lib/_pydecimal.py:5439–5469  ·  view source on GitHub ↗

Square root of a non-negative number to context precision. If the result must be inexact, it is rounded using the round-half-even algorithm. >>> ExtendedContext.sqrt(Decimal('0')) Decimal('0') >>> ExtendedContext.sqrt(Decimal('-0')) Decimal('-0')

(self, a)

Source from the content-addressed store, hash-verified

5437 return a.shift(b, context=self)
5438
5439 def sqrt(self, a):
5440 """Square root of a non-negative number to context precision.
5441
5442 If the result must be inexact, it is rounded using the round-half-even
5443 algorithm.
5444
5445 >>> ExtendedContext.sqrt(Decimal('0'))
5446 Decimal('0')
5447 >>> ExtendedContext.sqrt(Decimal('-0'))
5448 Decimal('-0')
5449 >>> ExtendedContext.sqrt(Decimal('0.39'))
5450 Decimal('0.624499800')
5451 >>> ExtendedContext.sqrt(Decimal('100'))
5452 Decimal('10')
5453 >>> ExtendedContext.sqrt(Decimal('1'))
5454 Decimal('1')
5455 >>> ExtendedContext.sqrt(Decimal('1.0'))
5456 Decimal('1.0')
5457 >>> ExtendedContext.sqrt(Decimal('1.00'))
5458 Decimal('1.0')
5459 >>> ExtendedContext.sqrt(Decimal('7'))
5460 Decimal('2.64575131')
5461 >>> ExtendedContext.sqrt(Decimal('10'))
5462 Decimal('3.16227766')
5463 >>> ExtendedContext.sqrt(2)
5464 Decimal('1.41421356')
5465 >>> ExtendedContext.prec
5466 9
5467 """
5468 a = _convert_other(a, raiseit=True)
5469 return a.sqrt(context=self)
5470
5471 def subtract(self, a, b):
5472 """Return the difference between the two operands.

Callers 1

test_sqrtMethod · 0.95

Calls 2

_convert_otherFunction · 0.85
sqrtMethod · 0.45

Tested by 1

test_sqrtMethod · 0.76