From Xojo Documentation
|You are currently browsing the old Xojo documentation site. Please visit the new Xojo documentation site!|
The \ operator is used to perform Integer division between two numbers.
result = expression1 \ expression2
|result||Integer||The Integer division of expression1 and expression2.|
|expression1||Number||Any numeric expression.|
|expression2||Number||Any numeric expression.|
Use this operator when you require division that does not consider the decimal portion of the expressions. The result may differ from systems that round the expressions prior to the division.
If expression1 and expression2 are not integers, they are coerced to Int32s. The result is an Integer. If you divide by zero, the result is undefined even if the numerator is also zero. The only expected behavior is the application will not crash. For that reason, you should always check to see whether the denominator is zero before using \.
When converting a floating point number to an Integer, there is always the chance of data loss. The same is true when a floating-point value holds a sentinel such as infinity or NaN. Integers do not reserve space for sentinel values, so that information is lost. Converting a floating-point number that represents a sentinel to an Integer yields undefined results.
You can use Operator_IntegerDivide to define the \ operator for classes.
This code stores the result of a division of two numbers in a variable: