Version: 1.1.0
Numeric types
Mojo's numeric story is SIMD-first. A scalar is a SIMD vector of width 1.
Essentials
DTypenames the element format: integer, float, or bool, plus a width in bits.SIMD[dtype, width]storeswidthelements.Intis the default signed integer.- Saturating and wrapping arithmetic are explicit methods, not secret operator modes.
- Literals convert into the dtype you store them in.
Example
def main():
var v = SIMD[DType.int32, 4](1, 2, 3, 4)
var w = v * 2
print(w)
Keep in mind
Pick the dtype the hardware implements well. A float64 path on a GPU that wants float32 is leaving speed on the table.