Dividing decimals yields invalid results in Python 2.5 to 2.7

后端 未结 2 1302
北荒
北荒 2021-01-17 12:19

After a very thorough read of the Python\'s decimal module documentation, I still find myself puzzled by what happens when I divide a decimal.

In Python 2.4.6 (makes

2条回答
  •  北荒
    北荒 (楼主)
    2021-01-17 12:30

    From your MacPorts bug, you have installed Xcode 4 and your version of Python 2.7.2 was built with the clang C compiler, rather than gcc-4.2. There is at least one known problem with building with clang on OS X that has been fixed in Python subsequent to the 2.7.2. release. Either apply the patch or, better, ensure the build uses gcc-4.2. Something like (untested!):

    sudo bash
    export CC=/usr/bin/gcc-4.2
    port clean python27
    port upgrade --force python27
    

    prior to the build might work if MacPorts doesn't override it.

    UPDATE: The required patch has now been applied to the MacPorts port files for Python 2. See https://trac.macports.org/changeset/87442

提交回复
热议问题