{"categories":["Python","\u6570\u5024\u8a08\u7b97"],"url":"https://hk29.hatenablog.jp/entry/2021/10/24/233436","width":"100%","blog_title":"Python\u3068VBA\u3067\u4e16\u306e\u4e2d\u3092\u4fbf\u5229\u306b\u3059\u308b","provider_url":"https://hatena.blog","published":"2021-10-24 23:34:36","height":"190","title":"Python \u5c0f\u6570\u70b9\u4ee5\u4e0b\u306e\u6841\u6570\u3067\u56db\u6368\u4e94\u5165\u3059\u308b\u300cDecimal\u300d","version":"1.0","type":"rich","image_url":"https://cdn-ak.f.st-hatena.com/images/fotolife/H/HK29/20211024/20211024232353.png","blog_url":"https://hk29.hatenablog.jp/","html":"<iframe src=\"https://hatenablog-parts.com/embed?url=https%3A%2F%2Fhk29.hatenablog.jp%2Fentry%2F2021%2F10%2F24%2F233436\" title=\"Python \u5c0f\u6570\u70b9\u4ee5\u4e0b\u306e\u6841\u6570\u3067\u56db\u6368\u4e94\u5165\u3059\u308b\u300cDecimal\u300d - Python\u3068VBA\u3067\u4e16\u306e\u4e2d\u3092\u4fbf\u5229\u306b\u3059\u308b\" class=\"embed-card embed-blogcard\" scrolling=\"no\" frameborder=\"0\" style=\"display: block; width: 100%; height: 190px; max-width: 500px; margin: 10px 0px;\"></iframe>","author_url":"https://blog.hatena.ne.jp/HK29/","description":"\u6a19\u6e96\u30e2\u30b8\u30e5\u30fc\u30eb\u306edecimal\u3092\u30a4\u30f3\u30dd\u30fc\u30c8\u3057\u3066\u4f7f\u7528\u3057\u307e\u3059\u3002 from decimal import Decimal, ROUND_HALF_UP pai = 3.141592 # \u56db\u6368\u4e94\u5165\u3057\u3066\u5c0f\u6570\u7b2c3\u4f4d\u307e\u3067\u306e\u6570\u5b57\u306b\u3059\u308b\uff08\u5c0f\u6570\u7b2c4\u4f4d\u3092\u56db\u6368\u4e94\u5165\uff09 a = Decimal(str(pai)).quantize(Decimal('0.001'), rounding=ROUND_HALF_UP) print(a, type(a)) \u4e0b\u56f3\u304c\u51fa\u529b\u7d50\u679c\u3067\u3059\u3002\u5c0f\u6570\u7b2c4\u4f4d\u304c5\u306e\u305f\u3081\u3001\u5c0f\u6570\u7b2c3\u4f4d\u304c1\u304b\u30892\u306b\u7e70\u308a\u4e0a\u304c\u3063\u3066\u307e\u3059\u3002 # \u56db\u6368\u4e94\u5165\u3057\u3066\u5c0f\u6570\u7b2c2\u4f4d\u307e\u3067\u306e\u6570\u5b57\u306b\u3059\u308b\uff08\u5c0f\u6570\u7b2c3\u4f4d\u3092\u56db\u6368\u4e94\u5165\uff09 b = Decimal\u2026","author_name":"HK29","provider_name":"Hatena Blog"}