aboutsummaryrefslogtreecommitdiff
path: root/lib/std/math/big
diff options
context:
space:
mode:
authorJan Prudil <57442prudil@sstebrno.eu>2020-10-17 14:09:59 +0200
committerJan Prudil <57442prudil@sstebrno.eu>2020-10-17 14:09:59 +0200
commitaadccc4206ea605719de789bc7c9c48557d02331 (patch)
tree631f4d25f6c8bf6cefdcbe58f3ac9f61434b6402 /lib/std/math/big
parent245d98d32dd29e80de9732f415a4731748008acf (diff)
downloadzig-aadccc4206ea605719de789bc7c9c48557d02331.tar.gz
zig-aadccc4206ea605719de789bc7c9c48557d02331.zip
Make std.meta.Int accept a signedness parameter
Diffstat (limited to 'lib/std/math/big')
-rw-r--r--lib/std/math/big/int.zig6
-rw-r--r--lib/std/math/big/rational.zig4
2 files changed, 5 insertions, 5 deletions
diff --git a/lib/std/math/big/int.zig b/lib/std/math/big/int.zig
index 25cafda9ac..a810334eb0 100644
--- a/lib/std/math/big/int.zig
+++ b/lib/std/math/big/int.zig
@@ -24,7 +24,7 @@ pub fn calcLimbLen(scalar: anytype) usize {
const T = @TypeOf(scalar);
switch (@typeInfo(T)) {
.Int => |info| {
- const UT = if (info.is_signed) std.meta.Int(false, info.bits - 1) else T;
+ const UT = if (info.is_signed) std.meta.Int(.unsigned, info.bits - 1) else T;
return @sizeOf(UT) / @sizeOf(Limb);
},
.ComptimeInt => {
@@ -187,7 +187,7 @@ pub const Mutable = struct {
switch (@typeInfo(T)) {
.Int => |info| {
- const UT = if (info.is_signed) std.meta.Int(false, info.bits - 1) else T;
+ const UT = if (info.is_signed) std.meta.Int(.unsigned, info.bits - 1) else T;
const needed_limbs = @sizeOf(UT) / @sizeOf(Limb);
assert(needed_limbs <= self.limbs.len); // value too big
@@ -1092,7 +1092,7 @@ pub const Const = struct {
pub fn to(self: Const, comptime T: type) ConvertError!T {
switch (@typeInfo(T)) {
.Int => |info| {
- const UT = std.meta.Int(false, info.bits);
+ const UT = std.meta.Int(.unsigned, info.bits);
if (self.bitCountTwosComp() > info.bits) {
return error.TargetTooSmall;
diff --git a/lib/std/math/big/rational.zig b/lib/std/math/big/rational.zig
index d75a7b599c..8eb1d9f2b3 100644
--- a/lib/std/math/big/rational.zig
+++ b/lib/std/math/big/rational.zig
@@ -136,7 +136,7 @@ pub const Rational = struct {
// Translated from golang.go/src/math/big/rat.go.
debug.assert(@typeInfo(T) == .Float);
- const UnsignedInt = std.meta.Int(false, @typeInfo(T).Float.bits);
+ const UnsignedInt = std.meta.Int(.unsigned, @typeInfo(T).Float.bits);
const f_bits = @bitCast(UnsignedInt, f);
const exponent_bits = math.floatExponentBits(T);
@@ -195,7 +195,7 @@ pub const Rational = struct {
debug.assert(@typeInfo(T) == .Float);
const fsize = @typeInfo(T).Float.bits;
- const BitReprType = std.meta.Int(false, fsize);
+ const BitReprType = std.meta.Int(.unsigned, fsize);
const msize = math.floatMantissaBits(T);
const msize1 = msize + 1;