Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Division questions
#4
The documentation says

Quote:The / (division) and // (floor division) operators yield the quotient of their arguments. The numeric arguments are first converted to a common type. Division of integers yields a float, while floor division of integers results in an integer; the result is that of mathematical division with the ‘floor’ function applied to the result.

So division ( / ) returns a float because that is what it is supposed to do.

The same goes for your floor division question. The documentation says 10 // -3 == floor(10 / -3).

The documentation for floor says this:

Quote:math.floor(x)
Return the floor of x, the largest integer less than or equal to x. If x is not a float, delegates to x.__floor__, which should return an Integral value.

10 / -3 = -3.3333.... floor(-3.3333...) = -4
swassilis likes this post
Reply


Messages In This Thread
Division questions - by Dionysis - Feb-13-2023, 10:27 PM
RE: Division questions - by Larz60+ - Feb-13-2023, 11:05 PM
RE: Division questions - by bowlofred - Feb-13-2023, 11:13 PM
RE: Division questions - by Dionysis - Feb-14-2023, 02:02 PM
RE: Division questions - by deanhystad - Feb-13-2023, 11:35 PM
RE: Division questions - by Larz60+ - Feb-14-2023, 11:44 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Division by zero and value of argument Lawu 5 3,423 Jul-01-2022, 02:28 PM
Last Post: Lawu
  Floor division problem with plotting x-axis tick labels Mark17 5 2,270 Apr-03-2022, 01:48 PM
Last Post: Mark17
  Division calcuation with answers to 1decimal place. sik 3 2,237 Jul-15-2021, 08:15 AM
Last Post: DeaD_EyE
  Floor division return value Chirumer 8 4,086 Nov-26-2020, 02:34 PM
Last Post: DeaD_EyE
  Integer division plozaq 2 2,069 Sep-28-2020, 05:49 PM
Last Post: plozaq
  Overcoming ZeroDivisionError: division by zero Error dgrunwal 8 5,265 Jun-12-2020, 01:52 PM
Last Post: dgrunwal
  Division of an integer into sub-numbers Richard_SS 4 3,119 Jun-14-2019, 11:47 AM
Last Post: DeaD_EyE
  Logic of using floor division and modulus for a different variable at different time SB_J 2 2,605 Nov-01-2018, 07:25 PM
Last Post: SB_J
  Discord bot that asks questions and based on response answers or asks more questions absinthium 1 51,663 Nov-25-2017, 06:21 AM
Last Post: heiner55

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020