「Python Decimal」の版間の差分
ナビゲーションに移動
検索に移動
1行目: | 1行目: | ||
− | ==Python Decimal== | + | ==[[Python Decimal]]== |
[[Python]] | | [[Python]] | | ||
− | + | [http://python.secsup.org/?p=138 Python Osmosis] | |
===Decimal=== | ===Decimal=== | ||
14行目: | 14行目: | ||
Personal firewall software may warn about the connection IDLE | Personal firewall software may warn about the connection IDLE | ||
makes to its subprocess using this computer's internal loopback | makes to its subprocess using this computer's internal loopback | ||
− | interface. This connection is not | + | interface. This connection is not [[vi]]sible on any external |
interface and no data is sent to or received from the Internet. | interface and no data is sent to or received from the Internet. | ||
**************************************************************** | **************************************************************** |
2020年2月16日 (日) 04:31時点における最新版
Python Decimal
Decimal
- from decimal で利用
- 小数点以下の計算も正しく行う
- getcontext().prec で有効桁数を設定
Python 2.6.3 (r263rc1:75186, Oct 2 2009, 20:40:30) [MSC v.1500 32 bit (Intel)] on win32 Type "copyright", "credits" or "license()" for more information. **************************************************************** Personal firewall software may warn about the connection IDLE makes to its subprocess using this computer's internal loopback interface. This connection is not visible on any external interface and no data is sent to or received from the Internet. **************************************************************** >>> from decimal import * >>> Decimal('0.70') * Decimal('1.05') Decimal('0.7350') >>> .70 * 1.05 0.73499999999999999 >>> Decimal('1.00') % Decimal('.10') Decimal('0.00') >>> 1.00 % 0.10 0.09999999999999995 >>> sum([Decimal('0.1')] * 10) == Decimal('1.0') True >>> sum([0.1] * 10) == 1.0 False >>> getcontext().prec = 36 >>> Decimal(1) / Decimal(7) Decimal('0.142857142857142857142857142857142857')
© 2006 矢木浩人