From df167af0b626479613732389d91e2b7d13f03dc6 Mon Sep 17 00:00:00 2001 From: Robin Voetter Date: Mon, 25 Oct 2021 14:00:10 +0200 Subject: [PATCH] Revert 83bdbb2 and a587dd0 (#10028) --- lib/std/math/big/int.zig | 11 ++++------- lib/std/math/big/rational.zig | 5 ----- 2 files changed, 4 insertions(+), 12 deletions(-) diff --git a/lib/std/math/big/int.zig b/lib/std/math/big/int.zig index 3b344f89db..5edf5b3ce5 100644 --- a/lib/std/math/big/int.zig +++ b/lib/std/math/big/int.zig @@ -18,14 +18,11 @@ const debug_safety = false; /// Returns the number of limbs needed to store `scalar`, which must be a /// primitive integer value. pub fn calcLimbLen(scalar: anytype) usize { - const T = @TypeOf(scalar); - const max_scalar = switch (@typeInfo(T)) { - .Int => maxInt(T), - .ComptimeInt => scalar, - else => @compileError("parameter must be a primitive integer type"), - }; + if (scalar == 0) { + return 1; + } - const w_value = std.math.absCast(max_scalar); + const w_value = std.math.absCast(scalar); return @divFloor(@intCast(Limb, math.log2(w_value)), limb_bits) + 1; } diff --git a/lib/std/math/big/rational.zig b/lib/std/math/big/rational.zig index 6f32968298..64f444eeca 100644 --- a/lib/std/math/big/rational.zig +++ b/lib/std/math/big/rational.zig @@ -4,8 +4,6 @@ const math = std.math; const mem = std.mem; const testing = std.testing; const Allocator = mem.Allocator; -const builtin = @import("builtin"); -const native_arch = builtin.target.cpu.arch; const Limb = std.math.big.Limb; const DoubleLimb = std.math.big.DoubleLimb; @@ -539,9 +537,6 @@ test "big.rational set" { } test "big.rational setFloat" { - // TODO https://github.com/ziglang/zig/issues/10026 - if (native_arch == .wasm32) return error.SkipZigTest; - var a = try Rational.init(testing.allocator); defer a.deinit();