| author | |
| committer | |
| log | 7c17f4c4b37804b8f7c01d85e0e4c54bdcf34e1d |
| tree | 2f74f7319e503093dbf5fff43f485e6e35210cec |
| parent | 26fd35ff902cb0f68ada18706e7f670b4aac3d4a |
2 files changed, 3 insertions(+), 3 deletions(-)
lib/std/math/big/int.zig+1-1| ... | @@ -35,7 +35,7 @@ const constants: Constants = blk: { | ... | @@ -35,7 +35,7 @@ const constants: Constants = blk: { |
| 35 | digits_per_limb[base] = @intCast(math.log(Limb, base, math.maxInt(Limb))); | 35 | digits_per_limb[base] = @intCast(math.log(Limb, base, math.maxInt(Limb))); |
| 36 | bases[base] = std.math.pow(Limb, base, digits_per_limb[base]); | 36 | bases[base] = std.math.pow(Limb, base, digits_per_limb[base]); |
| 37 | } | 37 | } |
| 38 | break :blk Constants{ .big_bases = bases, .digits_per_limb = digits_per_limb }; | 38 | break :blk .{ .big_bases = bases, .digits_per_limb = digits_per_limb }; |
| 39 | }; | 39 | }; |
| 40 | 40 | ||
| 41 | /// Returns the number of limbs needed to store `scalar`, which must be a | 41 | /// Returns the number of limbs needed to store `scalar`, which must be a |
lib/std/math/log10.zig+2-2| ... | @@ -58,9 +58,9 @@ pub fn log10_int(x: anytype) std.math.Log2Int(@TypeOf(x)) { | ... | @@ -58,9 +58,9 @@ pub fn log10_int(x: anytype) std.math.Log2Int(@TypeOf(x)) { |
| 58 | var log: u32 = 0; | 58 | var log: u32 = 0; |
| 59 | 59 | ||
| 60 | inline for (0..11) |i| { | 60 | inline for (0..11) |i| { |
| 61 | const num_digits = (1 << (11 - i)) * 5; | ||
| 61 | // Unnecessary branches should be removed by the compiler | 62 | // Unnecessary branches should be removed by the compiler |
| 62 | if (bit_size > (1 << (11 - i)) * 5 * @log2(10.0) and val >= pow10((1 << (11 - i)) * 5)) { | 63 | if (bit_size > num_digits * @log2(10.0) and val >= pow10(num_digits)) { |
| 63 | const num_digits = (1 << (11 - i)) * 5; | ||
| 64 | val /= pow10(num_digits); | 64 | val /= pow10(num_digits); |
| 65 | log += num_digits; | 65 | log += num_digits; |
| 66 | } | 66 | } |