How this integer division was defined in decimal class?
n = d * (n // d) + (n % d) still satisfied.
import decimal
from decimal import Decimal
x = -10
y = 3
print(x//y, x % y)
print(divmod(x, y))
print(x == y * (x//y) + (x % y))
# -4 2
# (-4, 2)
# True
a = Decimal('-10')
b = Decimal('3')
print(a//b, x % b)
print(divmod(a, b))
print(a == b * (a//b) + (a % b))
# -3 -1
# (Decimal('-3'), Decimal('-1'))
# True
Other Mathematical Operations
help(decimal)
import decimal
import math
from decimal import Decimal
decimal.getcontext().prec = 28
x = 0.01
x_dec = Decimal('0.01')
root = math.sqrt(x)
root_mixed = math.sqrt(x_dec)
root_dec = x_dec.sqrt(x_dec)
print(format(root, '1.27f'))
print(format(root_mixed, '1.27f'))
print(format(root_dec, '1.27f'))
# 0.100000000000000005551115123
# 0.100000000000000005551115123
# 0.100000000000000000000000000
print(format(root * root, '1.27f'))
print(format(root_mixed * root_mixed, '1.27f'))
print(format(root_dec * root_dec, '1.27f'))
# 0.010000000000000001942890293
# 0.010000000000000001942890293
# 0.010000000000000000000000000