authorgravatar for robin@voetter.nlRobin Voetter <robin@voetter.nl> 2021-10-01 20:50:44+02:00
committergravatar for robin@voetter.nlRobin Voetter <robin@voetter.nl> 2021-10-04 11:25:29+02:00
log96f095987f2f3a4d1be941b89afae0a706aad856
tree6d0a570de9de208fe720d578529382163f2bafcc
parent692827baa79590c20f09ae598b2c27663f72a207

Adapt Type.minInt and maxInt to use setTwosCompLimit


1 files changed, 4 insertions(+), 10 deletions(-)

src/type.zig+4-10
......@@ -3101,9 +3101,8 @@ pub const Type = extern union {
31013101 return Value.Tag.int_i64.create(arena, n);
31023102 }
31033103
3104 var res = try std.math.big.int.Managed.initSet(arena, 1);
3105 try res.shiftLeft(res, info.bits - 1);
3106 res.negate();
3104 var res = try std.math.big.int.Managed.init(arena);
3105 try res.setTwosCompIntLimit(.min, info.signedness, info.bits);
31073106
31083107 const res_const = res.toConst();
31093108 if (res_const.positive) {
......@@ -3126,13 +3125,8 @@ pub const Type = extern union {
31263125 return Value.Tag.int_u64.create(arena, n);
31273126 }
31283127
3129 var res = try std.math.big.int.Managed.initSet(arena, 1);
3130 try res.shiftLeft(res, info.bits - @boolToInt(info.signedness == .signed));
3131 const one = std.math.big.int.Const{
3132 .limbs = &[_]std.math.big.Limb{1},
3133 .positive = true,
3134 };
3135 res.sub(res.toConst(), one) catch unreachable;
3128 var res = try std.math.big.int.Managed.init(arena);
3129 try res.setTwosCompIntLimit(.max, info.signedness, info.bits);
31363130
31373131 const res_const = res.toConst();
31383132 if (res_const.positive) {