# Cast problem

This is a function to convert representation but its throwing an error I don’t understand. It seems to expect the value to be cast to already be the that type. Any help appreciated.
Bob

// Convert input buffer in i8 BE to output buffer f64 LE
// Input side of DSP
pub fn i8be_to_f64le(in_data: *[defs.DSP_BLK_SZ * 6]u8, out_data: [defs.DSP_BLK_SZ * 2]f64) void {
// The in_data is a i8 1024 complex samples where each each interleaved I and Q are 24 bits in BE format.
// Thus the length of the input data is 1024
6 representing the 1024 complex samples.
// The output data is 1024 complex samples in f64 LE format suitable for the DSP exchange function.

``````// Scale factors
var scale: f64 = 1.0 / (std.math.pow(f64, 2, 23));

// Size to iterate over
var sz: u32 = (defs.DSP_BLK_SZ * defs.BYTES_PER_SAMPLE) - defs.BYTES_PER_SAMPLE / 2;

var in_index: u32 = 0;
var out_index: u32 = 0;
var as_int: i32 = 0;

// Here we would iterate over each receiver and use a 2d array but for now one receiver.
// Pack the 3 x i8 BE bytes (24 bit sample) into an int in LE format.
// We must retain the sign hence we shift up to MSB and then down to propogate the sign.
while (in_index <= sz) {

// Big endian stores the most significant byte in the lowest address
// Little endian stores the most significant byte in the highest address
as_int =
((@as(i32, (in_data[(in_index + 2)])) << 8) |
(@as(i32, (in_data[(in_index + 1)])) << 16) |
(@as(i32, (in_data[(in_index)])) << 24)) >> 8;

// Scale and write to target array
out_data[out_index] = @as(f64, as_int) * scale;

// BYTES_PER_SAMPLE is complex sample but we are moving I and then Q so /2
in_index += defs.BYTES_PER_SAMPLE / 2;
out_index += 1;
}
``````

}

src\common\converters.zig:74:40: error: expected type ‘f64’, found ‘i32’
out_data[out_index] = @as(f64, as_int) * scale;
^~~~~~~
Note, the error should point to as_int.

try `@intToFloat()`