v2 / vlib / v / tests / casts / cast_f64_to_u64_boundary_test.v
14 lines · 12 sloc · 339 bytes · 51a5c3aa60764e2ec7521d240ee1a7587183d352
Raw
1import math
2
3fn test_f64_to_u64_boundary_values() {
4 max_u64 := u64(-1)
5 pow_63 := math.pow(2, 63)
6 pow_64 := math.pow(2, 64)
7 high_step := pow_63 + 2048.0
8
9 assert u64(-1.0) == 0
10 assert u64(pow_63) == u64(1) << 63
11 assert u64(high_step) == (u64(1) << 63) + u64(2048)
12 assert u64(pow_64) == max_u64
13 assert u64(f64(max_u64)) == max_u64
14}
15