• Catalog

    Catalog

    See All
    • Languages
    • Courses

    Languages

    See All
    • C++
    • C#
    • HTML
    • Java
    • JavaScript
    • Python
    • C
    • CSS

    Level

    See All
    • Beginner
    • Intermediate
    • Advanced

    Courses

    See All
    • Introduction to Python
    • Introduction to C
    • Introduction to C#
    • Introduction to SQL
    • Introduction to HTML
    • Introduction to CSS
    • Introduction to Java
    • Introduction to JavaScript
    • Introduction to C++
    • Tech for Everyone

    Courses

    See All
    • C# Intermediate
    • Python Intermediate
    • Java Intermediate
    • JavaScript Intermediate
    • C++ Intermediate
    • C Intermediate
    • SQL Intermediate
    • Game Development with JS

    Courses

    See All
    • React + Redux
    • Angular + NestJS
    • Python Data Structures
  • Online Compiler
    • HTML
    • CSS
    • Javascript
    • C++
    • C
    • PHP
    • Java
    • Python
    • Swift
    • C#
    • Ruby
    • Node.JS
    • Kotlin
    • jQuery
    • Go
    • R
    • TypeScript
  • Discuss
  • Blog
  • Get Pro
Menu
+ 1

Why the results are different? (floor division)

Why they are not the outputs 3 and -3 or 4 and -4? print (-11//3) # output -4 print (11//3) # output 3

pythondivisionfloor
22nd Mar 2017, 11:31 AM
Javier I. Rivera R.
Javier I. Rivera R. - avatar
1 Answer
+ 11
Floor division works this way - it does not round to zero. Rather, it always returns the next lower integer, whether positive or negative.
22nd Mar 2017, 11:44 AM
Kuba Siekierzyński
Kuba Siekierzyński - avatar

Often have questions like this?

Learn more efficiently, for free:

  • Introduction to Python

    7.1M learners

  • Introduction to Java

    4.7M learners

  • Introduction to C

    1.5M learners

  • Introduction to HTML

    7.5M learners

See all courses
Hot today
If i give space in my input it does not shows next words
1 Votes
FIX ERROR in my code ,project guesser game ,code in description
1 Votes
Modulus,Python: why 1 not 0? 1 fitst 2 times in 2, leaving 0 as a result? why 1 not 0?
0 Votes
How to make a full wed
0 Votes
Which function is used to access files?
0 Votes
How to anticipate single or multiple input failure(s) when input(s) are read in using C++ std::cin and extraction operator >>
4 Votes
This program is running multiple times
0 Votes
Matrix in cryptography
0 Votes
Asking for another solution for this project
1 Votes
Можете помочь с этим кодом.Нужно вычислить процент прибыли,если бы скидка была дана только для людей с заданным вводным возрасто
0 Votes

Languages

  • C++
  • C#
  • HTML
  • Java
  • JavaScript
  • Python
  • C
  • CSS

Introduction Courses

  • Introduction to Python
  • Introduction to C
  • Introduction to C#
  • Introduction to SQL
  • Introduction to HTML
  • Introduction to CSS
  • Introduction to Java
  • Introduction to JavaScript
  • Introduction to C++
  • Tech for Everyone
  • R
  • Kotlin
  • Go
  • PHP
  • Ruby
  • Swift 4

Intermediate Courses

  • C# Intermediate
  • Python Intermediate
  • Java Intermediate
  • JavaScript Intermediate
  • C++ Intermediate
  • C Intermediate
  • SQL Intermediate
  • Game Development with JS

Advanced Courses

  • React + Redux
  • Angular + NestJS
  • Python Data Structures

Community

  • Discuss
  • Code Bits
  • Blog
Follow us on Linkedin
Check out our facebook
See what we tweet about
Join our instagram
Watch our Youtube
HomeTop LearnersProFAQContactBug Bounty ProgramCareersTerms of UsePrivacy PolicySololearn mobile
Made with
by  Sololearn | ©2023