Updated 2026-11-25
No language uses ÷
Every mainstream programming language, spreadsheet and calculator app divides with the slash /. The ÷ character is only text: 84 ÷ 4 is a syntax error in Python, JavaScript, Java and C. What does differ between languages is what / returns for whole numbers, how negative numbers round, how the remainder operator % handles signs, and what happens when you divide by zero.
Python: /, //, % and divmod()
7 / 2 # 3.5 true division, always a float 7 // 2 # 3 floor division -7 // 2 # -4 rounds DOWN, not toward zero 7 % 2 # 1 -7 % 2 # 1 result has the sign of the divisor 7 % -2 # -1 divmod(-7, 2) # (-4, 1) int(-7 / 2) # -3 truncates toward zero 1 / 0 # raises ZeroDivisionError (1.0 / 0 too)
Python guarantees that (a // b) * b + a % b equals a, so floor division and modulo always agree. If you want C-style truncation, use int(a / b) for small values or math.fmod(-7, 2) (gives −1.0) for the remainder.
JavaScript
7 / 2 // 3.5 all numbers are floating point Math.trunc(-7 / 2) // -3 integer part, toward zero Math.floor(-7 / 2) // -4 floor -7 % 2 // -1 % keeps the sign of the DIVIDEND 7 % -2 // 1 1 / 0 // Infinity (no error) -1 / 0 // -Infinity 0 / 0 // NaN 7n / 2n // 3n BigInt division truncates 1n / 0n // throws RangeError
Because % follows the dividend's sign, -7 % 2 is −1 in JavaScript but 1 in Python. For a always-positive modulo use ((a % b) + b) % b.
Integer division by language
| Language | 7 / 2 | -7 / 2 | -7 % 2 | Integer ÷ 0 |
|---|---|---|---|---|
| Python 3 | 3.5 (use // → 3) | −3.5 (// → −4) | 1 | ZeroDivisionError |
| JavaScript | 3.5 | −3.5 | −1 | Infinity (BigInt: RangeError) |
| C / C++ | 3 | −3 | −1 | Undefined behavior |
| Java | 3 | −3 | −1 | ArithmeticException |
| C# | 3 | −3 | −1 | DivideByZeroException |
| Go | 3 | −3 | −1 | Runtime panic |
| Rust | 3 | −3 | −1 | Panic |
| Ruby | 3 | −4 | 1 | ZeroDivisionError |
| Excel / Sheets | 3.5 | −3.5 | MOD(-7,2) = 1 | #DIV/0! |
In C, C++, Java, C#, Go and Rust, / on two integers truncates toward zero and % takes the sign of the dividend. Python and Ruby floor instead, and their % takes the sign of the divisor. Java offers Math.floorDiv(-7, 2) = −4 and Math.floorMod(-7, 2) = 1; Rust has div_euclid and rem_euclid. Dividing floating-point numbers by zero (for example 1.0 / 0 in C or Java) follows IEEE 754 and gives infinity rather than an error, except in Python, which raises an exception.
Which rounding is "right"?
Both conventions satisfy dividend = divisor × quotient + remainder; they just choose different quotients for negative numbers. For −7 ÷ 2:
- Truncation: quotient −3, remainder −1, because 2 × (−3) + (−1) = −7.
- Floor: quotient −4, remainder 1, because 2 × (−4) + 1 = −7.
School arithmetic usually wants a remainder between 0 and the divisor, which matches the floor rule for positive divisors. Our remainder calculator shows both results side by side, and the long division calculator shows the written method for positive numbers.
Spreadsheets and SQL
- Excel and Google Sheets:
=A2/B2,QUOTIENT()(truncates),MOD()(sign of divisor). Google Sheets also hasDIVIDE(). Details on division in Excel. - PostgreSQL and SQL Server: dividing two integers truncates (
7/2= 3); cast one side to a decimal for 3.5. Division by zero raises an error. - MySQL:
7/2returns 3.5000; use7 DIV 2for integer division. By default1/0returns NULL.
Need ÷ in a string, for example in a quiz app? Use "\u00F7" in most languages; the full list of escapes is on the division symbol HTML code page.
Frequently asked questions
What is the division symbol in programming?
The forward slash /. No programming language accepts ÷ as an operator.
What does // mean in Python?
Floor division: it divides and rounds down to a whole number. 7 // 2 is 3 and -7 // 2 is -4.
What is the difference between / and % ?
/ gives the quotient and % gives the remainder. In Python 7 % 3 is 1; for negative numbers the sign rules differ between languages.
Why is -7 % 2 different in Python and JavaScript?
Python's % takes the sign of the divisor (result 1), while JavaScript's % takes the sign of the dividend (result -1).
What happens when you divide by zero in code?
Python raises ZeroDivisionError; JavaScript returns Infinity or NaN; Java and C# throw exceptions for integers; in C and C++ integer division by zero is undefined behavior.
How do I do integer division in JavaScript?
Use Math.trunc(a / b) to round toward zero or Math.floor(a / b) to round down. BigInt values such as 7n / 2n divide as integers.