Telegram Group & Telegram Channel
چالش اعداد اعشاری در پایتون!
یکی از مشکلاتی که در برخی زبان های برنامه نویسی از جمله پایتون با آن مواجه می شویم، چالش کار با اعداد اعشاری است. به دو عبارت زیر توجه کنید:
0.1 + 0.1  == 0.2
True
0.1 + 0.1 + 0.1 == 0.3
False

مساله از اینجا شروع می شود که پایتون برای محاسبات خود، اعداد را به باینری تبدیل می کند که این مسئله، محاسبات اعداد اعشاری را در برخی موارد دچار مشکل می کند.
برای حل این موضوع می توان از تابع isclose در ماژول math استفاده کرد.
math.isclose(0.1 + 0.1 + 0.1, 0.3)
True

لازم است در تحلیل هایی که نیاز به بررسی اعداد اعشاری دارند، این مورد را حتما در نظر بگیرید.

پایتون برای مالی

🆔 @python4finance



tg-me.com/python4finance/1053
Create:
Last Update:

چالش اعداد اعشاری در پایتون!
یکی از مشکلاتی که در برخی زبان های برنامه نویسی از جمله پایتون با آن مواجه می شویم، چالش کار با اعداد اعشاری است. به دو عبارت زیر توجه کنید:

0.1 + 0.1  == 0.2
True
0.1 + 0.1 + 0.1 == 0.3
False

مساله از اینجا شروع می شود که پایتون برای محاسبات خود، اعداد را به باینری تبدیل می کند که این مسئله، محاسبات اعداد اعشاری را در برخی موارد دچار مشکل می کند.
برای حل این موضوع می توان از تابع isclose در ماژول math استفاده کرد.
math.isclose(0.1 + 0.1 + 0.1, 0.3)
True

لازم است در تحلیل هایی که نیاز به بررسی اعداد اعشاری دارند، این مورد را حتما در نظر بگیرید.

پایتون برای مالی

🆔 @python4finance

BY Python4Finance


Warning: Undefined variable $i in /var/www/tg-me/post.php on line 283

Share with your friend now:
tg-me.com/python4finance/1053

View MORE
Open in Telegram


Python4Finance Telegram | DID YOU KNOW?

Date: |

The STAR Market, as is implied by the name, is heavily geared toward smaller innovative tech companies, in particular those engaged in strategically important fields, such as biopharmaceuticals, 5G technology, semiconductors, and new energy. The STAR Market currently has 340 listed securities. The STAR Market is seen as important for China’s high-tech and emerging industries, providing a space for smaller companies to raise capital in China. This is especially significant for technology companies that may be viewed with suspicion on overseas stock exchanges.

How Does Bitcoin Mining Work?

Bitcoin mining is the process of adding new transactions to the Bitcoin blockchain. It’s a tough job. People who choose to mine Bitcoin use a process called proof of work, deploying computers in a race to solve mathematical puzzles that verify transactions.To entice miners to keep racing to solve the puzzles and support the overall system, the Bitcoin code rewards miners with new Bitcoins. “This is how new coins are created” and new transactions are added to the blockchain, says Okoro.

Python4Finance from us


Telegram Python4Finance
FROM USA