| author | |
| committer | |
| log | df167af0b626479613732389d91e2b7d13f03dc6 |
| tree | b97462b505a267e7d51bbc5681fa07dfb667d5c3 |
| parent | a587dd08f86bf8524b9dc405044b9b48a735db18 |
| signature |
2 files changed, 4 insertions(+), 12 deletions(-)
lib/std/math/big/int.zig+4-7| ... | @@ -18,14 +18,11 @@ const debug_safety = false; | ... | @@ -18,14 +18,11 @@ const debug_safety = false; |
| 18 | /// Returns the number of limbs needed to store `scalar`, which must be a | 18 | /// Returns the number of limbs needed to store `scalar`, which must be a |
| 19 | /// primitive integer value. | 19 | /// primitive integer value. |
| 20 | pub fn calcLimbLen(scalar: anytype) usize { | 20 | pub fn calcLimbLen(scalar: anytype) usize { |
| 21 | const T = @TypeOf(scalar); | 21 | if (scalar == 0) { |
| 22 | const max_scalar = switch (@typeInfo(T)) { | 22 | return 1; |
| 23 | .Int => maxInt(T), | 23 | } |
| 24 | .ComptimeInt => scalar, | ||
| 25 | else => @compileError("parameter must be a primitive integer type"), | ||
| 26 | }; | ||
| 27 | 24 | ||
| 28 | const w_value = std.math.absCast(max_scalar); | 25 | const w_value = std.math.absCast(scalar); |
| 29 | return @divFloor(@intCast(Limb, math.log2(w_value)), limb_bits) + 1; | 26 | return @divFloor(@intCast(Limb, math.log2(w_value)), limb_bits) + 1; |
| 30 | } | 27 | } |
| 31 | 28 |
lib/std/math/big/rational.zig-5| ... | @@ -4,8 +4,6 @@ const math = std.math; | ... | @@ -4,8 +4,6 @@ const math = std.math; |
| 4 | const mem = std.mem; | 4 | const mem = std.mem; |
| 5 | const testing = std.testing; | 5 | const testing = std.testing; |
| 6 | const Allocator = mem.Allocator; | 6 | const Allocator = mem.Allocator; |
| 7 | const builtin = @import("builtin"); | ||
| 8 | const native_arch = builtin.target.cpu.arch; | ||
| 9 | 7 | ||
| 10 | const Limb = std.math.big.Limb; | 8 | const Limb = std.math.big.Limb; |
| 11 | const DoubleLimb = std.math.big.DoubleLimb; | 9 | const DoubleLimb = std.math.big.DoubleLimb; |
| ... | @@ -539,9 +537,6 @@ test "big.rational set" { | ... | @@ -539,9 +537,6 @@ test "big.rational set" { |
| 539 | } | 537 | } |
| 540 | 538 | ||
| 541 | test "big.rational setFloat" { | 539 | test "big.rational setFloat" { |
| 542 | // TODO https://github.com/ziglang/zig/issues/10026 | ||
| 543 | if (native_arch == .wasm32) return error.SkipZigTest; | ||
| 544 | |||
| 545 | var a = try Rational.init(testing.allocator); | 540 | var a = try Rational.init(testing.allocator); |
| 546 | defer a.deinit(); | 541 | defer a.deinit(); |
| 547 | 542 |