-3

I'm testing big integers in Python; they are implemented as an object with sign and an array of digits. It's, basically, to describe Karatsuba Multiplication, and, for those big integers, I need the same behaviour like oridinary numbers with integer division by 10, and, there is a problem:
Why, in Python, -22 // 10 = -3?

Tom
  • 55
  • 7

1 Answers1

2

Dividing by // is a floor division.

Floor division goes to the lower number without a .

  • 22 // 10 results to the next lower value 2.

  • -22 // 10 results to the next lower value -3

To do a normal division you can run -22 / 10 This results into

- 2.2
basti500
  • 600
  • 4
  • 20