【问题标题】:Unexpected output when using exponent operator(**) with float value in Python在 Python 中使用带浮点值的指数运算符(**)时出现意外输出
【发布时间】:2018-05-08 02:12:42
【问题描述】:

我目前在 Windows 7 中使用 Python 3.6。

当我将指数运算符 (**) 与给出大数字的浮点数一起使用时,我得到了一个意外的输出。

例如,“10^32”的输出是不同的,无论指数是整数 (32) 还是浮点数 (32.0)。

   >>>print (int(10**(32.0)))
   100000000000000005366162204393472

   >>>print (int(10**(32)))
   100000000000000000000000000000000

Using "**"operator in Python(example)

输出不同有什么原因吗?

如果是这样,我该如何解决这个问题?

【问题讨论】:

标签: python python-3.x exponentiation


【解决方案1】:

【讨论】:

    猜你喜欢
    • 2021-08-09
    • 2022-01-05
    • 2022-01-05
    • 2020-05-08
    • 2021-09-28
    • 1970-01-01
    • 2022-10-13
    • 1970-01-01
    • 2021-02-07
    相关资源
    最近更新 更多