feat: add as type casting
This commit is contained in:
@@ -0,0 +1,21 @@
|
||||
[code]
|
||||
fn promote_f32_to_f64(x: f32) -> f64 {
|
||||
return x as f64;
|
||||
}
|
||||
|
||||
fn demote_f64_to_f32(x: f64) -> f32 {
|
||||
return x as f32;
|
||||
}
|
||||
|
||||
[harness]
|
||||
extern double promote_f32_to_f64(float x);
|
||||
extern float demote_f64_to_f32(double x);
|
||||
|
||||
int main() {
|
||||
if (promote_f32_to_f64(3.5f) != 3.5) return 1;
|
||||
if (demote_f64_to_f32(2.25) != 2.25f) return 2;
|
||||
return 0;
|
||||
}
|
||||
|
||||
[expected_return_code]
|
||||
0
|
||||
Reference in New Issue
Block a user