Python

decimal module

Në shqip: Moduli decimal

ShpjegimiSQ

float-i s'i ruan saktë numrat dhjetorë (0.1 + 0.2 ≠ 0.3). Moduli decimal i ruan saktë — përdore për para dhe llogaritje financiare. Krijoji nga tekst: Decimal("0.10").

EnglishEN

float can't store decimals exactly (0.1 + 0.2 ≠ 0.3). The decimal module stores them exactly — use it for money and financial calculations. Create them from text: Decimal("0.10").

Si ta mendosh

Si ta numërosh paranë qindarkë për qindarkë.

Lexoje në anglisht

Like counting money cent by cent.

Shembull kodipython

from decimal import Decimal
print(0.1 + 0.2)                          # 0.30000000000000004
print(Decimal("0.1") + Decimal("0.2"))    # 0.3

Terma të lidhur