authorgravatar for robin@voetter.nlRobin Voetter <robin@voetter.nl> 2021-10-25 14:00:10+02:00
committergravatar for noreply@github.comGitHub <noreply@github.com> 2021-10-25 14:00:10+02:00
logdf167af0b626479613732389d91e2b7d13f03dc6
treeb97462b505a267e7d51bbc5681fa07dfb667d5c3
parenta587dd08f86bf8524b9dc405044b9b48a735db18
signaturebadge-question-mark Signed by PGP key 4AEE18F83AFDEB23

Revert 83bdbb2 and a587dd0 (#10028)


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 a18/// Returns the number of limbs needed to store `scalar`, which must be a
19/// primitive integer value.19/// primitive integer value.
20pub fn calcLimbLen(scalar: anytype) usize {20pub 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 };
2724
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}
3128
lib/std/math/big/rational.zig-5
...@@ -4,8 +4,6 @@ const math = std.math;...@@ -4,8 +4,6 @@ const math = std.math;
4const mem = std.mem;4const mem = std.mem;
5const testing = std.testing;5const testing = std.testing;
6const Allocator = mem.Allocator;6const Allocator = mem.Allocator;
7const builtin = @import("builtin");
8const native_arch = builtin.target.cpu.arch;
97
10const Limb = std.math.big.Limb;8const Limb = std.math.big.Limb;
11const DoubleLimb = std.math.big.DoubleLimb;9const DoubleLimb = std.math.big.DoubleLimb;
...@@ -539,9 +537,6 @@ test "big.rational set" {...@@ -539,9 +537,6 @@ test "big.rational set" {
539}537}
540538
541test "big.rational setFloat" {539test "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();
547542