Skip to main content

Mojo function

bitcast

bitcast[type: DType, width: Int, //, new_type: DType, new_width: Int = $1](val: SIMD[type, width]) -> SIMD[$2, $3]

Bitcasts a SIMD value to another SIMD value.

Constraints:

The bitwidth of the two types must be the same.

Parameters:

  • type (DType): The source type.
  • width (Int): The source width.
  • new_type (DType): The target type.
  • new_width (Int): The target width.

Args:

  • val (SIMD[type, width]): The source value.

Returns:

A new SIMD value with the specified type and width with a bitcopy of the source SIMD value.