warp.cast ========= .. function:: warp._src.lang.cast(a: Any, dtype: Any) -> Any .. hlist:: :columns: 8 * Kernel Reinterpret a value as a different type while preserving its bit pattern. :param a: The value to cast :param dtype: The target type. .. rubric:: Example .. code-block:: python @wp.struct class MyStruct: f: wp.float16 i: wp.int16 @wp.kernel def compute(): x = wp.int32(0x40000000) x_casted = wp.cast(x, wp.float32) wp.expect_eq(x_casted, 2.0) # 0x40000000 s = MyStruct() s.f = wp.float16(2.0) # 0x4000 s.i = wp.int16(4096) # 0x1000 s_casted = wp.cast(s, wp.int32) wp.expect_eq(s_casted, 0x10004000) wp.launch(compute, dim=1)