Type Conversion - chung-leong/qb GitHub Wiki
The majority of operators in PHP+QB expect operands belonging to the same primitive type. When there is a mismatch, type conversion occurs. For instance, if $a is int32 and $b is float32, when you add the two, $a must be converted to float32 first.
Typically, "lower rank" types are converted to "higher rank" types. Types with less precisions and/or range are promoted to those with greater precision and range in order to preserve both. Primitive types in QB are ranked in accordance with the following rules:
- A wider type ranks above a narrower type (e.g. int64 > int32)
- Floating points rank higher than any integer type (e.g. float32 > int64)
- Unsigned integers rank higher than signed integer of the same size (e.g. uint32 > int32)
The order from highest to lowest is thus:
- float64
- float32
- uint64
- int64
- uint32
- int32
- uint16
- int16
- uint8
- int8