feat: add as type casting
This commit is contained in:
@@ -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
|
||||
Reference in New Issue
Block a user