feat: add as type casting

This commit is contained in:
2026-04-22 22:40:19 +02:00
parent e66a4ee736
commit 041a49e574
13 changed files with 350 additions and 1 deletions
+24
View File
@@ -0,0 +1,24 @@
[code]
fn cast_f32_to_i32(x: f32) -> i32 {
return x as i32;
}
fn cast_f64_to_u64(x: f64) -> u64 {
return x as u64;
}
[harness]
#include <stdint.h>
extern int32_t cast_f32_to_i32(float x);
extern uint64_t cast_f64_to_u64(double x);
int main() {
if (cast_f32_to_i32(3.14f) != 3) return 1;
if (cast_f32_to_i32(-2.9f) != -2) return 2;
if (cast_f64_to_u64(42.999) != 42) return 3;
return 0;
}
[expected_return_code]
0