mirror of
https://github.com/kmc7468/cs420.git
synced 2025-12-16 15:38:48 +00:00
Fix ir interpreter
This commit is contained in:
@@ -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))
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user