When you create an expression involving data of different types, MapInfo performs automatic type conversion in order to produce meaningful results. For example, if your program subtracts a Date value from another Date value, MapBasic will calculate the result as an integer value (representing the number of days between the two dates).
The table below summarizes the rules that dictate MapBasic's automatic type conversions. Within this chart, the keyword Integer represents an integer value, which can be an integer variable, a SmallInt variable, or an integer constant. The keyword Number represents a numeric expression which is not necessarily an integer.
Operator | Combination of Operands | Result |
---|---|---|
+ |
Date + Number |
Date |
Number + Date |
Date |
|
Integer + Integer |
Integer |
|
Number + Number |
Float |
|
Other + Other |
String |
|
- |
Date - Number |
Date |
Date - Date |
Integer |
|
Integer - Integer |
Integer |
|
Number - Number |
Float |
|
* |
Integer * Integer |
Integer |
Number * Number |
Float |
|
/ |
Number / Number |
Float |
\ |
Number \ Number |
Integer |
MOD |
Number MOD Number |
Integer |
^ |
Number ^ Number |
Float |