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.
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 ...
๐ŸŒ
Oreate AI
oreateai.com โ€บ blog โ€บ understanding-the-operator-in-python-a-guide-to-floor-division โ€บ aa990ff53ac355b48f800163112f6990
Understanding the // Operator in Python: A Guide to Floor Division - Oreate AI Blog
December 30, 2025 - In Python, the // operator is known as the floor division operator. It divides two numbers and returns the largest whole number that is less than or equal to the result of that division.
๐ŸŒ
Google
google.com โ€บ goto
Modulo, floor division, and modular arithmetic
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.
๐ŸŒ
Threads
threads.com โ€บ @codingcomputing โ€บ post โ€บ C7s0bGICiFM
The // operator is called the floor division operator. It's very ...
June 1, 2024 - Like say 22 // 5Here a normal division would give the answer 4.4But what floor division does is, it simply rounds down 4.4 to 4.Isn't this familiar as the Quotient of the division?What if we had 22 // -5Normal division would give -4.4 here.+
๐ŸŒ
Google
google.com โ€บ goto
Floor Division in Python: Everything You Need to Know
February 5, 2026 - The Floor Division operator // available for both integers and floating-point numbers also. However, the chief feature with this method is that it always truncates the decimal part no matter if the result of division is an integer or not. On the other hand, it is different from the most division problems that yield a floating-point answer. The // operator works by performing division and then rounding down the result to the nearest integer.
๐ŸŒ
Dallas County Clerk
dallascounty.org โ€บ government โ€บ county-clerk โ€บ criminal-courts
County Clerk | Criminal Courts Division - Home
Frank Crowley Courts Building - ... 2nd Floor, Room A-1, Dallas, TX 75207 Phone: (214) 653-7099 Hours: 8:00 a.m. - 4:30 p.m., Monday - Friday (except for court approved holidays) The Dallas County Clerk is now offering Electronic Certified Official Public Record (OPR) Documents and Court Documents for purchase on the Clerk's website. Each electronic certified document uses advanced encrypted features to produce a ...
๐ŸŒ
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.
๐ŸŒ
Google
google.com โ€บ goto
Don't Confuse Integer Division with Floor Division
July 15, 2021 - 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 ...