You can do

double val = 5 / 2;
int answer = Math.floor(val);

OR

int answer = Math.floorDiv(5, 2);

If you were to call System.out.println(answer); the output would be

2

Answer from A J on Stack Overflow
๐ŸŒ
GeeksforGeeks
geeksforgeeks.org โ€บ python โ€บ floor-division-in-python
Floor Division in Python - GeeksforGeeks
July 23, 2025 - In result, we are performing floor division between a float (7.5) and an integer (2). The result of dividing 7.5 by 2 is 3.75, but floor division truncates the fractional part, resulting in 3.0. ... This code uses math.floor() to round down the result of -10 / 3, and it prints the rounded-down integer value, which is -4.
๐ŸŒ
LearnDataSci
learndatasci.com โ€บ solutions โ€บ python-double-slash-operator-floor-division
Python Double Slash (//) Operator: Floor Division โ€“ LearnDataSci
In Python, we can perform floor division (also sometimes known as integer division) using the // operator. This operator will divide the first argument by the second and round the result down to the nearest whole number, making it equivalent to the math.floor() function.
Discussions

Java - How to do floor division? - Stack Overflow
I know that in Python you can do floor division like this: 5 // 2 #2 The // is used for something totally different in Java. Is there any way to do floor division in Java? More on stackoverflow.com
๐ŸŒ stackoverflow.com
What is floor division?
Floor division is a type of division operation in mathematics and computer programming that rounds down the result to the nearest integer less than or equal to the division result. This operation is useful when you need the quotient as an integer without any fractional or decimal part. More on designgurus.io
๐ŸŒ designgurus.io
1
10
June 25, 2024
What's the difference between % (modulo) and // (floor division)
There's a function called divmod that does both, and if you use that a few times, you'll get a feel for the difference. For example, let's say you have a quantity of money, and you want to make change. cents = 93 quarters, cents = divmod(cents, 25) dimes, cents = divmod(cents, 10) nickels, cents = divmod(cents, 5) At each step, we take as many chunks as we can (that's the div), then we keep any leftovers (that's the mod) More on reddit.com
๐ŸŒ r/learnpython
9
0
September 15, 2024
How do The Summit Checkpoints work
Yes you go back to the check point but Iโ€™m not sure if you start at a checkpoint if you were with a group More on reddit.com
๐ŸŒ r/thedivision
19
7
October 30, 2020
People also ask

What is the difference between floor division (//) and regular division (/) in Python?
The key difference between floor division (//) and regular division (/) in Python is how they handle the result. Floor division returns the largest integer less than or equal to the division result, effectively truncating any decimal portion.

For example, 7 // 2 results in 3, whereas 7 / 2 results in 3.5. Use floor division when you need an integer result.
๐ŸŒ
metaschool.so
metaschool.so โ€บ home โ€บ answers โ€บ what is floor division in python? guide with examples
What is Floor Division in Python? Guide With Examples
How can floor division be useful in blockchain development?
Floor division can be particularly useful in blockchain development for calculating whole numbers required in various scenarios. For instance, it can help determine how many transactions can fit in a block, calculate fees that must be rounded down to avoid fractional values, or evenly distribute resources among nodes in a network. Using floor division ensures that all calculations yield integer results, which are often essential in these contexts.
๐ŸŒ
metaschool.so
metaschool.so โ€บ home โ€บ answers โ€บ what is floor division in python? guide with examples
What is Floor Division in Python? Guide With Examples
When should I use math.floor() instead of math.round()?
Use math.floor() when you want to round down to the nearest integer, regardless of the decimal value. For example, math.floor(3.7) returns 3. In contrast, math.round() rounds to the nearest integer, meaning math.round(3.7) returns 4, and math.round(3.4) returns 3.

Choose math.floor() when you need consistent downward rounding and math.round() when you want standard rounding behavior.
๐ŸŒ
metaschool.so
metaschool.so โ€บ home โ€บ answers โ€บ what is floor division in python? guide with examples
What is Floor Division in Python? Guide With Examples
๐ŸŒ
Mimo
mimo.org โ€บ glossary โ€บ python โ€บ floor-division
Python Floor Division: Syntax, Usage, and Examples
Floor division in Python refers to an operation that divides two numbers and truncates the decimal part of the result, returning only the integer portion. For example: ... While standard division (/) would return 3.5, the double slash operator drops everything after the decimal point, giving you 3.
๐ŸŒ
Codecademy
codecademy.com โ€บ forum_questions โ€บ 5384587e52f863dcb8001c82
what is floor division // | Codecademy
2.5 would fit in the middle. Floor division means the โ€œ//โ€œ will always take the floor or the lower number. ... In this SQL course, you'll learn how to manage large datasets and analyze real data using the standard data ...
Find elsewhere
๐ŸŒ
W3Schools
w3schools.com โ€บ python โ€บ python_operators_arithmetic.asp
Python Arithmetic Operators
Floor division always returns an integer. ... If you want to use W3Schools services as an educational institution, team or enterprise, send us an e-mail: sales@w3schools.com
๐ŸŒ
AlgoCademy
algocademy.com โ€บ link
Floor Division in JavaScript | AlgoCademy
โ€” true division, always float ... Math.floor(a / b) * b + (a % b) === a // 3 * 3 + 1 === 10 โœ“ ยท Math.floor() rounds toward negative infinity (always down)....
๐ŸŒ
Metaschool
metaschool.so โ€บ home โ€บ answers โ€บ what is floor division in python? guide with examples
What is Floor Division in Python? Guide With Examples
December 6, 2024 - The most straightforward way to perform floor division is by using the // operator. This operator divides two numbers and automatically rounds down to the nearest whole number.
๐ŸŒ
Wikipedia
en.wikipedia.org โ€บ wiki โ€บ Floor_and_ceiling_functions
Floor and ceiling functions - Wikipedia
February 5, 2026 - Assuming such shifts are "premature ... with division can break software. Many programming languages (including C, C++, C#, Java, Julia, PHP, R, and Python) provide standard functions for floor and ceiling, usually called floor and ceil, or less commonly ceiling. The language APL uses โŒŠx for floor. The J Programming Language, a follow-on to APL that is ...
๐ŸŒ
University of Vermont
uvm.edu โ€บ ~cbcafier โ€บ cs1210 โ€บ book โ€บ 04_variables,_statements,_and_expressions โ€บ modulo_and_floor.html
Modulo, floor division, and modular arithmetic โ€“ Clayton Cafiero
June 26, 2025 - Why does 17 // -5 yield -4 and not -3? Remember that this is whatโ€™s called โ€œfloor division.โ€ What Python does, is that it calculates the (floating-point) quotient and then applies the floor function. The floor function is a mathematical function which, given some number x, returns the greatest integer less than or equal to x.
๐ŸŒ
Marcelkliemannel
marcelkliemannel.com โ€บ articles โ€บ 2021 โ€บ dont-confuse-integer-division-with-floor-division
Don't Confuse Integer Division with Floor Division | Marcel Kliemannel
To better understand the problem behind it, we will implement the modulo operation once with the floor and once with the integer division. The modulo operation returns the signed remainder of a division, e.g., 7 modulo 5 would be 2 because 5 fits one time into 7 remaining 2. Let us take a slightly modified equation from Donald ...
๐ŸŒ
The Teclado Blog
blog.teclado.com โ€บ pythons-modulo-operator-and-floor-division
Python's modulo operator and floor division
October 26, 2022 - -4 is considered less than -3.333 recurring. It's further left on the number line. This means that floor division will always round away from zero for negative numbers, but towards zero for positive numbers.
๐ŸŒ
GeeksforGeeks
geeksforgeeks.org โ€บ python โ€บ what-does-floor-division-mean-in-python
What does // mean in Python ? - GeeksforGeeks
July 23, 2025 - In Python, the // operator is known as the floor division operator. It is used to perform division between two numbers while rounding down the result to the nearest whole number. This behaviour is different from the regular division operator ...
๐ŸŒ
Educative
educative.io โ€บ answers โ€บ floor-division
Floor division
Floor division is a division operation that rounds the result down to the nearest whole number or integer, which is less than or equal to the normal division result.
๐ŸŒ
Quora
quora.com โ€บ What-is-floor-division
What is floor division (//)? - Quora
Answer (1 of 9): Floor division is done using two forward slashes and is used to determine the quotient of a division (the quantity produced by the division of two numbers). Example: print(5//2) Output: 2
๐ŸŒ
Sololearn
sololearn.com โ€บ en โ€บ Discuss โ€บ 2236776 โ€บ what-is-floor-division-and-modulo-division
What is floor division and modulo division? | Sololearn: Learn to code for FREE!
Floor will round the decimal down and uses the / operator in most languages I know eg. 5 / 2 = 2 no decimal after the 2 Modulo division returns the remainder and uses the % operator 5 % 2 = 1 ... Thank you very much.