@bitCast
@bitCast
@bitCast(value: anytype) anytype
Converts a value of one type to another type. The return type is the inferred result type.
Asserts that @sizeOf(@TypeOf(value)) == @sizeOf(DestType).
Asserts that @typeInfo(DestType) != .Pointer. Use @ptrCast or @ptrFromInt if you need this.
Can be used for these things for example:
- Convert
f32tou32bits - Convert
i32tou32preserving twos complement
Works at compile-time if value is known at compile time. It’s a compile error to bitcast a value of undefined layout; this means that, besides the restriction from types which possess dedicated casting builtins (enums, pointers, error sets), bare structs, error unions, slices, optionals, and any other type without a well-defined memory layout, also cannot be used in this operation.
