| author | |
| committer | |
| log | ab585c680b3222b01c1520ac33d1233ba1ba5036 |
| tree | 672ef073ad223e860a998f72bc2a047d287b1ca9 |
| parent | 7b150dd05ed3e647897e6f3b0beb08e10e73c92e |
The base is 2^64 and not 2^64-1.
Closes #66832 files changed, 20 insertions(+), 0 deletions(-)
src/stage1/bigfloat.cpp+4| ... | @@ -46,6 +46,10 @@ void bigfloat_init_bigint(BigFloat *dest, const BigInt *op) { | ... | @@ -46,6 +46,10 @@ void bigfloat_init_bigint(BigFloat *dest, const BigInt *op) { |
| 46 | 46 | ||
| 47 | float128_t base; | 47 | float128_t base; |
| 48 | ui64_to_f128M(UINT64_MAX, &base); | 48 | ui64_to_f128M(UINT64_MAX, &base); |
| 49 | float128_t one_f128; | ||
| 50 | ui32_to_f128M(1, &one_f128); | ||
| 51 | f128M_add(&base, &one_f128, &base); | ||
| 52 | |||
| 49 | const uint64_t *digits = bigint_ptr(op); | 53 | const uint64_t *digits = bigint_ptr(op); |
| 50 | 54 | ||
| 51 | for (size_t i = op->digit_count - 1;;) { | 55 | for (size_t i = op->digit_count - 1;;) { |
test/stage1/behavior/cast.zig+16| ... | @@ -375,6 +375,22 @@ test "comptime_int @intToFloat" { | ... | @@ -375,6 +375,22 @@ test "comptime_int @intToFloat" { |
| 375 | expect(@TypeOf(result) == f32); | 375 | expect(@TypeOf(result) == f32); |
| 376 | expect(result == 1234.0); | 376 | expect(result == 1234.0); |
| 377 | } | 377 | } |
| 378 | { | ||
| 379 | const result = @intToFloat(f64, 1234); | ||
| 380 | expect(@TypeOf(result) == f64); | ||
| 381 | expect(result == 1234.0); | ||
| 382 | } | ||
| 383 | { | ||
| 384 | const result = @intToFloat(f128, 1234); | ||
| 385 | expect(@TypeOf(result) == f128); | ||
| 386 | expect(result == 1234.0); | ||
| 387 | } | ||
| 388 | // big comptime_int (> 64 bits) to f128 conversion | ||
| 389 | { | ||
| 390 | const result = @intToFloat(f128, 0x1_0000_0000_0000_0000); | ||
| 391 | expect(@TypeOf(result) == f128); | ||
| 392 | expect(result == 0x1_0000_0000_0000_0000.0); | ||
| 393 | } | ||
| 378 | } | 394 | } |
| 379 | 395 | ||
| 380 | test "@intCast i32 to u7" { | 396 | test "@intCast i32 to u7" { |