Fix ir interpreter

This commit is contained in:
Minseong Jang
2022-03-28 15:27:35 +09:00
parent 2947d4350f
commit 4def8318f7

View File

@@ -770,10 +770,17 @@ mod calculator {
}, },
Dtype::Float { width, .. }, Dtype::Float { width, .. },
) => { ) => {
let casted_value = if is_signed { let size = (width - 1) / Dtype::BITS_OF_BYTE + 1;
value as i128 as f64 let casted_value = match (is_signed, size) {
} else { (true, Dtype::SIZE_OF_FLOAT) => value as i128 as f32 as f64,
value as f64 (true, Dtype::SIZE_OF_DOUBLE) => value as i128 as f64,
(false, Dtype::SIZE_OF_FLOAT) => value as f32 as f64,
(false, Dtype::SIZE_OF_DOUBLE) => value as f64,
_ => panic!(
"calculate_typecast: not supported case \
typecast int to float when `width` is {}",
width
),
}; };
Ok(Value::float(casted_value, width)) Ok(Value::float(casted_value, width))
} }