• <bdo id='SyHrf'></bdo><ul id='SyHrf'></ul>

  1. <legend id='SyHrf'><style id='SyHrf'><dir id='SyHrf'><q id='SyHrf'></q></dir></style></legend>
    1. <small id='SyHrf'></small><noframes id='SyHrf'>

      <tfoot id='SyHrf'></tfoot>

    2. <i id='SyHrf'><tr id='SyHrf'><dt id='SyHrf'><q id='SyHrf'><span id='SyHrf'><b id='SyHrf'><form id='SyHrf'><ins id='SyHrf'></ins><ul id='SyHrf'></ul><sub id='SyHrf'></sub></form><legend id='SyHrf'></legend><bdo id='SyHrf'><pre id='SyHrf'><center id='SyHrf'></center></pre></bdo></b><th id='SyHrf'></th></span></q></dt></tr></i><div id='SyHrf'><tfoot id='SyHrf'></tfoot><dl id='SyHrf'><fieldset id='SyHrf'></fieldset></dl></div>

    3. 负数楼层划分

      Floor division with negative number(负数楼层划分)

        <tbody id='hBP0x'></tbody>
          <tfoot id='hBP0x'></tfoot>
            <legend id='hBP0x'><style id='hBP0x'><dir id='hBP0x'><q id='hBP0x'></q></dir></style></legend>

            <small id='hBP0x'></small><noframes id='hBP0x'>

                <bdo id='hBP0x'></bdo><ul id='hBP0x'></ul>

                <i id='hBP0x'><tr id='hBP0x'><dt id='hBP0x'><q id='hBP0x'><span id='hBP0x'><b id='hBP0x'><form id='hBP0x'><ins id='hBP0x'></ins><ul id='hBP0x'></ul><sub id='hBP0x'></sub></form><legend id='hBP0x'></legend><bdo id='hBP0x'><pre id='hBP0x'><center id='hBP0x'></center></pre></bdo></b><th id='hBP0x'></th></span></q></dt></tr></i><div id='hBP0x'><tfoot id='hBP0x'></tfoot><dl id='hBP0x'><fieldset id='hBP0x'></fieldset></dl></div>
                本文介绍了负数楼层划分的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                问题描述

                The expression 6 // 4 yields 1, where floor division produces the whole number after dividing a number.

                But with a negative number, why does -6 // 4 return -2?

                解决方案

                The // operator explicitly floors the result. Quoting the Binary arithmetic operations documentation:

                the result is that of mathematical division with the ‘floor’ function applied to the result.

                Flooring is not the same thing as rounding to 0; flooring always moves to the lower integer value. See the math.floor() function:

                Return the floor of x, the largest integer less than or equal to x.

                For -6 // 4, first the result of -6 / 4 is calculated, so -1.5. Flooring then moves to the lower integer value, so -2.

                If you want to round towards zero instead, you'll have to do so explicitly; you could do this with the int() function on true division:

                >>> int(-6 / 4)
                -1
                

                int() removes the decimal portion, so always rounds towards zero instead.

                这篇关于负数楼层划分的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

                相关文档推荐

                Split a Pandas column of lists into multiple columns(将 Pandas 的列表列拆分为多列)
                How does the @property decorator work in Python?(@property 装饰器在 Python 中是如何工作的?)
                What is the difference between old style and new style classes in Python?(Python中的旧样式类和新样式类有什么区别?)
                How to break out of multiple loops?(如何打破多个循环?)
                How to put the legend out of the plot(如何将传说从情节中剔除)
                Why is the output of my function printing out quot;Nonequot;?(为什么我的函数输出打印出“无?)
              • <legend id='sOr2K'><style id='sOr2K'><dir id='sOr2K'><q id='sOr2K'></q></dir></style></legend>

                    <bdo id='sOr2K'></bdo><ul id='sOr2K'></ul>

                    • <tfoot id='sOr2K'></tfoot>
                        <tbody id='sOr2K'></tbody>
                    • <small id='sOr2K'></small><noframes id='sOr2K'>

                        1. <i id='sOr2K'><tr id='sOr2K'><dt id='sOr2K'><q id='sOr2K'><span id='sOr2K'><b id='sOr2K'><form id='sOr2K'><ins id='sOr2K'></ins><ul id='sOr2K'></ul><sub id='sOr2K'></sub></form><legend id='sOr2K'></legend><bdo id='sOr2K'><pre id='sOr2K'><center id='sOr2K'></center></pre></bdo></b><th id='sOr2K'></th></span></q></dt></tr></i><div id='sOr2K'><tfoot id='sOr2K'></tfoot><dl id='sOr2K'><fieldset id='sOr2K'></fieldset></dl></div>