« MySQL Pop Quiz #16 | Main | MySQL Function of the Day: Week 2 »
DIV :: MySQL Function of the Day
By Carsten | March 18, 2008
Function name: DIV
Aliases: -
Function type: Numeric operator
Purpose: Integer division
Description: DIV is actually an operator, not a function. I’m including it in this series none the less, as there are no functions with similar functionality.
DIV performs integer division. That is, it divides one integer by another and throws away any decimal part in the result. Some examples:
5 DIV 2 => 2 7 DIV 3 => 2 29 DIV 5 => 5
Both operands are converted to integer before the actual division. In the following examples, 7,5 is converted to 8 and 2.4999 converted to 2 before division takes place:
7.5 DIV 1=> 8 2.4999 DIV 1 => 2 7.5 DIV 2.4999 => 4
[fadps]
Topics: MySQL Function of the day |