| author | |
| committer | |
| log | 9f48b2ab48bcd6cfba45b8dfc60d0ad9633b294e |
| tree | f4b01cbfcebc40284d0b7fe7aec3f371e32fc799 |
| parent | 814a34f263cbfeabbf7a898b3b70fa781baaccac |
Closes #495.8 files changed, 32 insertions(+), 32 deletions(-)
std/special/compiler_rt/floattidf.zig+2-2| ... | @@ -42,12 +42,12 @@ pub extern fn __floattidf(arg: i128) f64 { | ... | @@ -42,12 +42,12 @@ pub extern fn __floattidf(arg: i128) f64 { |
| 42 | } | 42 | } |
| 43 | // finish | 43 | // finish |
| 44 | a |= @boolToInt((a & 4) != 0); // Or P into R | 44 | a |= @boolToInt((a & 4) != 0); // Or P into R |
| 45 | a +%= 1; // round - this step may add a significant bit | 45 | a += 1; // round - this step may add a significant bit |
| 46 | a >>= 2; // dump Q and R | 46 | a >>= 2; // dump Q and R |
| 47 | // a is now rounded to DBL_MANT_DIG or DBL_MANT_DIG+1 bits | 47 | // a is now rounded to DBL_MANT_DIG or DBL_MANT_DIG+1 bits |
| 48 | if ((a & (u128(1) << DBL_MANT_DIG)) != 0) { | 48 | if ((a & (u128(1) << DBL_MANT_DIG)) != 0) { |
| 49 | a >>= 1; | 49 | a >>= 1; |
| 50 | e +%= 1; | 50 | e += 1; |
| 51 | } | 51 | } |
| 52 | // a is now rounded to DBL_MANT_DIG bits | 52 | // a is now rounded to DBL_MANT_DIG bits |
| 53 | } else { | 53 | } else { |
std/special/compiler_rt/floattisf.zig+2-2| ... | @@ -43,12 +43,12 @@ pub extern fn __floattisf(arg: i128) f32 { | ... | @@ -43,12 +43,12 @@ pub extern fn __floattisf(arg: i128) f32 { |
| 43 | } | 43 | } |
| 44 | // finish | 44 | // finish |
| 45 | a |= @boolToInt((a & 4) != 0); // Or P into R | 45 | a |= @boolToInt((a & 4) != 0); // Or P into R |
| 46 | a +%= 1; // round - this step may add a significant bit | 46 | a += 1; // round - this step may add a significant bit |
| 47 | a >>= 2; // dump Q and R | 47 | a >>= 2; // dump Q and R |
| 48 | // a is now rounded to FLT_MANT_DIG or FLT_MANT_DIG+1 bits | 48 | // a is now rounded to FLT_MANT_DIG or FLT_MANT_DIG+1 bits |
| 49 | if ((a & (u128(1) << FLT_MANT_DIG)) != 0) { | 49 | if ((a & (u128(1) << FLT_MANT_DIG)) != 0) { |
| 50 | a >>= 1; | 50 | a >>= 1; |
| 51 | e +%= 1; | 51 | e += 1; |
| 52 | } | 52 | } |
| 53 | // a is now rounded to FLT_MANT_DIG bits | 53 | // a is now rounded to FLT_MANT_DIG bits |
| 54 | } else { | 54 | } else { |
std/special/compiler_rt/floattitf.zig+2-2| ... | @@ -42,12 +42,12 @@ pub extern fn __floattitf(arg: i128) f128 { | ... | @@ -42,12 +42,12 @@ pub extern fn __floattitf(arg: i128) f128 { |
| 42 | } | 42 | } |
| 43 | // finish | 43 | // finish |
| 44 | a |= @boolToInt((a & 4) != 0); // Or P into R | 44 | a |= @boolToInt((a & 4) != 0); // Or P into R |
| 45 | a +%= 1; // round - this step may add a significant bit | 45 | a += 1; // round - this step may add a significant bit |
| 46 | a >>= 2; // dump Q and R | 46 | a >>= 2; // dump Q and R |
| 47 | // a is now rounded to LDBL_MANT_DIG or LDBL_MANT_DIG+1 bits | 47 | // a is now rounded to LDBL_MANT_DIG or LDBL_MANT_DIG+1 bits |
| 48 | if ((a & (u128(1) << LDBL_MANT_DIG)) != 0) { | 48 | if ((a & (u128(1) << LDBL_MANT_DIG)) != 0) { |
| 49 | a >>= 1; | 49 | a >>= 1; |
| 50 | e +%= 1; | 50 | e += 1; |
| 51 | } | 51 | } |
| 52 | // a is now rounded to LDBL_MANT_DIG bits | 52 | // a is now rounded to LDBL_MANT_DIG bits |
| 53 | } else { | 53 | } else { |
std/special/compiler_rt/floatunditf.zig+1-1| ... | @@ -1,6 +1,6 @@ | ... | @@ -1,6 +1,6 @@ |
| 1 | const builtin = @import("builtin"); | 1 | const builtin = @import("builtin"); |
| 2 | const is_test = builtin.is_test; | 2 | const is_test = builtin.is_test; |
| 3 | const std = @import("../../index.zig"); | 3 | const std = @import("std"); |
| 4 | 4 | ||
| 5 | pub extern fn __floatunditf(a: u128) f128 { | 5 | pub extern fn __floatunditf(a: u128) f128 { |
| 6 | @setRuntimeSafety(is_test); | 6 | @setRuntimeSafety(is_test); |
std/special/compiler_rt/floatunsitf.zig+1-1| ... | @@ -1,6 +1,6 @@ | ... | @@ -1,6 +1,6 @@ |
| 1 | const builtin = @import("builtin"); | 1 | const builtin = @import("builtin"); |
| 2 | const is_test = builtin.is_test; | 2 | const is_test = builtin.is_test; |
| 3 | const std = @import("../../index.zig"); | 3 | const std = @import("std"); |
| 4 | 4 | ||
| 5 | pub extern fn __floatunsitf(a: u64) f128 { | 5 | pub extern fn __floatunsitf(a: u64) f128 { |
| 6 | @setRuntimeSafety(is_test); | 6 | @setRuntimeSafety(is_test); |
std/special/compiler_rt/floatuntidf.zig+8-8| ... | @@ -11,8 +11,8 @@ pub extern fn __floatuntidf(arg: u128) f64 { | ... | @@ -11,8 +11,8 @@ pub extern fn __floatuntidf(arg: u128) f64 { |
| 11 | 11 | ||
| 12 | var a = arg; | 12 | var a = arg; |
| 13 | const N: u32 = @sizeOf(u128) * 8; | 13 | const N: u32 = @sizeOf(u128) * 8; |
| 14 | const sd = @bitCast(i32, N -% @clz(a)); // number of significant digits | 14 | const sd = @bitCast(i32, N - @clz(a)); // number of significant digits |
| 15 | var e: i32 = sd -% 1; // exponent | 15 | var e: i32 = sd - 1; // exponent |
| 16 | if (sd > DBL_MANT_DIG) { | 16 | if (sd > DBL_MANT_DIG) { |
| 17 | // start: 0000000000000000000001xxxxxxxxxxxxxxxxxxxxxxPQxxxxxxxxxxxxxxxxxx | 17 | // start: 0000000000000000000001xxxxxxxxxxxxxxxxxxxxxxPQxxxxxxxxxxxxxxxxxx |
| 18 | // finish: 000000000000000000000000000000000000001xxxxxxxxxxxxxxxxxxxxxxPQR | 18 | // finish: 000000000000000000000000000000000000001xxxxxxxxxxxxxxxxxxxxxxPQR |
| ... | @@ -27,28 +27,28 @@ pub extern fn __floatuntidf(arg: u128) f64 { | ... | @@ -27,28 +27,28 @@ pub extern fn __floatuntidf(arg: u128) f64 { |
| 27 | }, | 27 | }, |
| 28 | DBL_MANT_DIG + 2 => {}, | 28 | DBL_MANT_DIG + 2 => {}, |
| 29 | else => { | 29 | else => { |
| 30 | const shift_amt = @bitCast(i32, N +% (DBL_MANT_DIG + 2)) -% sd; | 30 | const shift_amt = @bitCast(i32, N + (DBL_MANT_DIG + 2)) - sd; |
| 31 | const shift_amt_u7 = @intCast(u7, shift_amt); | 31 | const shift_amt_u7 = @intCast(u7, shift_amt); |
| 32 | a = (a >> @intCast(u7, sd -% (DBL_MANT_DIG + 2))) | | 32 | a = (a >> @intCast(u7, sd - (DBL_MANT_DIG + 2))) | |
| 33 | @boolToInt((a & (u128(@maxValue(u128)) >> shift_amt_u7)) != 0); | 33 | @boolToInt((a & (u128(@maxValue(u128)) >> shift_amt_u7)) != 0); |
| 34 | }, | 34 | }, |
| 35 | } | 35 | } |
| 36 | // finish | 36 | // finish |
| 37 | a |= @boolToInt((a & 4) != 0); // Or P into R | 37 | a |= @boolToInt((a & 4) != 0); // Or P into R |
| 38 | a +%= 1; // round - this step may add a significant bit | 38 | a += 1; // round - this step may add a significant bit |
| 39 | a >>= 2; // dump Q and R | 39 | a >>= 2; // dump Q and R |
| 40 | // a is now rounded to DBL_MANT_DIG or DBL_MANT_DIG+1 bits | 40 | // a is now rounded to DBL_MANT_DIG or DBL_MANT_DIG+1 bits |
| 41 | if ((a & (u128(1) << DBL_MANT_DIG)) != 0) { | 41 | if ((a & (u128(1) << DBL_MANT_DIG)) != 0) { |
| 42 | a >>= 1; | 42 | a >>= 1; |
| 43 | e +%= 1; | 43 | e += 1; |
| 44 | } | 44 | } |
| 45 | // a is now rounded to DBL_MANT_DIG bits | 45 | // a is now rounded to DBL_MANT_DIG bits |
| 46 | } else { | 46 | } else { |
| 47 | a <<= @intCast(u7, DBL_MANT_DIG -% sd); | 47 | a <<= @intCast(u7, DBL_MANT_DIG - sd); |
| 48 | // a is now rounded to DBL_MANT_DIG bits | 48 | // a is now rounded to DBL_MANT_DIG bits |
| 49 | } | 49 | } |
| 50 | 50 | ||
| 51 | const high: u64 = @bitCast(u32, (e +% 1023) << 20) | // exponent | 51 | const high: u64 = @bitCast(u32, (e + 1023) << 20) | // exponent |
| 52 | (@truncate(u32, a >> 32) & 0x000FFFFF); // mantissa-high | 52 | (@truncate(u32, a >> 32) & 0x000FFFFF); // mantissa-high |
| 53 | const low = @truncate(u32, a); // mantissa-low | 53 | const low = @truncate(u32, a); // mantissa-low |
| 54 | 54 |
std/special/compiler_rt/floatuntisf.zig+8-8| ... | @@ -11,8 +11,8 @@ pub extern fn __floatuntisf(arg: u128) f32 { | ... | @@ -11,8 +11,8 @@ pub extern fn __floatuntisf(arg: u128) f32 { |
| 11 | 11 | ||
| 12 | var a = arg; | 12 | var a = arg; |
| 13 | const N: u32 = @sizeOf(u128) * 8; | 13 | const N: u32 = @sizeOf(u128) * 8; |
| 14 | const sd = @bitCast(i32, N -% @clz(a)); // number of significant digits | 14 | const sd = @bitCast(i32, N - @clz(a)); // number of significant digits |
| 15 | var e: i32 = sd -% 1; // exponent | 15 | var e: i32 = sd - 1; // exponent |
| 16 | if (sd > FLT_MANT_DIG) { | 16 | if (sd > FLT_MANT_DIG) { |
| 17 | // start: 0000000000000000000001xxxxxxxxxxxxxxxxxxxxxxPQxxxxxxxxxxxxxxxxxx | 17 | // start: 0000000000000000000001xxxxxxxxxxxxxxxxxxxxxxPQxxxxxxxxxxxxxxxxxx |
| 18 | // finish: 000000000000000000000000000000000000001xxxxxxxxxxxxxxxxxxxxxxPQR | 18 | // finish: 000000000000000000000000000000000000001xxxxxxxxxxxxxxxxxxxxxxPQR |
| ... | @@ -27,28 +27,28 @@ pub extern fn __floatuntisf(arg: u128) f32 { | ... | @@ -27,28 +27,28 @@ pub extern fn __floatuntisf(arg: u128) f32 { |
| 27 | }, | 27 | }, |
| 28 | FLT_MANT_DIG + 2 => {}, | 28 | FLT_MANT_DIG + 2 => {}, |
| 29 | else => { | 29 | else => { |
| 30 | const shift_amt = @bitCast(i32, N +% (FLT_MANT_DIG + 2)) -% sd; | 30 | const shift_amt = @bitCast(i32, N + (FLT_MANT_DIG + 2)) - sd; |
| 31 | const shift_amt_u7 = @intCast(u7, shift_amt); | 31 | const shift_amt_u7 = @intCast(u7, shift_amt); |
| 32 | a = (a >> @intCast(u7, sd -% (FLT_MANT_DIG + 2))) | | 32 | a = (a >> @intCast(u7, sd - (FLT_MANT_DIG + 2))) | |
| 33 | @boolToInt((a & (u128(@maxValue(u128)) >> shift_amt_u7)) != 0); | 33 | @boolToInt((a & (u128(@maxValue(u128)) >> shift_amt_u7)) != 0); |
| 34 | }, | 34 | }, |
| 35 | } | 35 | } |
| 36 | // finish | 36 | // finish |
| 37 | a |= @boolToInt((a & 4) != 0); // Or P into R | 37 | a |= @boolToInt((a & 4) != 0); // Or P into R |
| 38 | a +%= 1; // round - this step may add a significant bit | 38 | a += 1; // round - this step may add a significant bit |
| 39 | a >>= 2; // dump Q and R | 39 | a >>= 2; // dump Q and R |
| 40 | // a is now rounded to FLT_MANT_DIG or FLT_MANT_DIG+1 bits | 40 | // a is now rounded to FLT_MANT_DIG or FLT_MANT_DIG+1 bits |
| 41 | if ((a & (u128(1) << FLT_MANT_DIG)) != 0) { | 41 | if ((a & (u128(1) << FLT_MANT_DIG)) != 0) { |
| 42 | a >>= 1; | 42 | a >>= 1; |
| 43 | e +%= 1; | 43 | e += 1; |
| 44 | } | 44 | } |
| 45 | // a is now rounded to FLT_MANT_DIG bits | 45 | // a is now rounded to FLT_MANT_DIG bits |
| 46 | } else { | 46 | } else { |
| 47 | a <<= @intCast(u7, FLT_MANT_DIG -% sd); | 47 | a <<= @intCast(u7, FLT_MANT_DIG - sd); |
| 48 | // a is now rounded to FLT_MANT_DIG bits | 48 | // a is now rounded to FLT_MANT_DIG bits |
| 49 | } | 49 | } |
| 50 | 50 | ||
| 51 | const high = @bitCast(u32, (e +% 127) << 23); // exponent | 51 | const high = @bitCast(u32, (e + 127) << 23); // exponent |
| 52 | const low = @truncate(u32, a) & 0x007fffff; // mantissa | 52 | const low = @truncate(u32, a) & 0x007fffff; // mantissa |
| 53 | 53 | ||
| 54 | return @bitCast(f32, high | low); | 54 | return @bitCast(f32, high | low); |
std/special/compiler_rt/floatuntitf.zig+8-8| ... | @@ -11,8 +11,8 @@ pub extern fn __floatuntitf(arg: u128) f128 { | ... | @@ -11,8 +11,8 @@ pub extern fn __floatuntitf(arg: u128) f128 { |
| 11 | 11 | ||
| 12 | var a = arg; | 12 | var a = arg; |
| 13 | const N: u32 = @sizeOf(u128) * 8; | 13 | const N: u32 = @sizeOf(u128) * 8; |
| 14 | const sd = @bitCast(i32, N -% @clz(a)); // number of significant digits | 14 | const sd = @bitCast(i32, N - @clz(a)); // number of significant digits |
| 15 | var e: i32 = sd -% 1; // exponent | 15 | var e: i32 = sd - 1; // exponent |
| 16 | if (sd > LDBL_MANT_DIG) { | 16 | if (sd > LDBL_MANT_DIG) { |
| 17 | // start: 0000000000000000000001xxxxxxxxxxxxxxxxxxxxxxPQxxxxxxxxxxxxxxxxxx | 17 | // start: 0000000000000000000001xxxxxxxxxxxxxxxxxxxxxxPQxxxxxxxxxxxxxxxxxx |
| 18 | // finish: 000000000000000000000000000000000000001xxxxxxxxxxxxxxxxxxxxxxPQR | 18 | // finish: 000000000000000000000000000000000000001xxxxxxxxxxxxxxxxxxxxxxPQR |
| ... | @@ -27,28 +27,28 @@ pub extern fn __floatuntitf(arg: u128) f128 { | ... | @@ -27,28 +27,28 @@ pub extern fn __floatuntitf(arg: u128) f128 { |
| 27 | }, | 27 | }, |
| 28 | LDBL_MANT_DIG + 2 => {}, | 28 | LDBL_MANT_DIG + 2 => {}, |
| 29 | else => { | 29 | else => { |
| 30 | const shift_amt = @bitCast(i32, N +% (LDBL_MANT_DIG + 2)) -% sd; | 30 | const shift_amt = @bitCast(i32, N + (LDBL_MANT_DIG + 2)) - sd; |
| 31 | const shift_amt_u7 = @intCast(u7, shift_amt); | 31 | const shift_amt_u7 = @intCast(u7, shift_amt); |
| 32 | a = (a >> @intCast(u7, sd -% (LDBL_MANT_DIG + 2))) | | 32 | a = (a >> @intCast(u7, sd - (LDBL_MANT_DIG + 2))) | |
| 33 | @boolToInt((a & (u128(@maxValue(u128)) >> shift_amt_u7)) != 0); | 33 | @boolToInt((a & (u128(@maxValue(u128)) >> shift_amt_u7)) != 0); |
| 34 | }, | 34 | }, |
| 35 | } | 35 | } |
| 36 | // finish | 36 | // finish |
| 37 | a |= @boolToInt((a & 4) != 0); // Or P into R | 37 | a |= @boolToInt((a & 4) != 0); // Or P into R |
| 38 | a +%= 1; // round - this step may add a significant bit | 38 | a += 1; // round - this step may add a significant bit |
| 39 | a >>= 2; // dump Q and R | 39 | a >>= 2; // dump Q and R |
| 40 | // a is now rounded to LDBL_MANT_DIG or LDBL_MANT_DIG+1 bits | 40 | // a is now rounded to LDBL_MANT_DIG or LDBL_MANT_DIG+1 bits |
| 41 | if ((a & (u128(1) << LDBL_MANT_DIG)) != 0) { | 41 | if ((a & (u128(1) << LDBL_MANT_DIG)) != 0) { |
| 42 | a >>= 1; | 42 | a >>= 1; |
| 43 | e +%= 1; | 43 | e += 1; |
| 44 | } | 44 | } |
| 45 | // a is now rounded to LDBL_MANT_DIG bits | 45 | // a is now rounded to LDBL_MANT_DIG bits |
| 46 | } else { | 46 | } else { |
| 47 | a <<= @intCast(u7, LDBL_MANT_DIG -% sd); | 47 | a <<= @intCast(u7, LDBL_MANT_DIG - sd); |
| 48 | // a is now rounded to LDBL_MANT_DIG bits | 48 | // a is now rounded to LDBL_MANT_DIG bits |
| 49 | } | 49 | } |
| 50 | 50 | ||
| 51 | const high: u128 = (@intCast(u64, (e +% 16383)) << 48) | // exponent | 51 | const high: u128 = (@intCast(u64, (e + 16383)) << 48) | // exponent |
| 52 | (@truncate(u64, a >> 64) & 0x0000ffffffffffff); // mantissa-high | 52 | (@truncate(u64, a >> 64) & 0x0000ffffffffffff); // mantissa-high |
| 53 | const low = @truncate(u64, a); // mantissa-low | 53 | const low = @truncate(u64, a); // mantissa-low |
| 54 | 54 |