| ... | @@ -30,7 +30,7 @@ pub fn calcLimbLen(scalar: anytype) usize { | ... | @@ -30,7 +30,7 @@ pub fn calcLimbLen(scalar: anytype) usize { |
| 30 | } | 30 | } |
| 31 | | 31 | |
| 32 | const w_value = std.math.absCast(scalar); | 32 | const w_value = std.math.absCast(scalar); |
| 33 | return @divFloor(@intCast(Limb, math.log2(w_value)), limb_bits) + 1; | 33 | return @intCast(usize, @divFloor(@intCast(Limb, math.log2(w_value)), limb_bits) + 1); |
| 34 | } | 34 | } |
| 35 | | 35 | |
| 36 | pub fn calcToStringLimbsBufferLen(a_len: usize, base: u8) usize { | 36 | pub fn calcToStringLimbsBufferLen(a_len: usize, base: u8) usize { |
| ... | @@ -238,10 +238,7 @@ pub const Mutable = struct { | ... | @@ -238,10 +238,7 @@ pub const Mutable = struct { |
| 238 | var i: usize = 0; | 238 | var i: usize = 0; |
| 239 | while (true) : (i += 1) { | 239 | while (true) : (i += 1) { |
| 240 | self.limbs[i] = @truncate(Limb, w_value); | 240 | self.limbs[i] = @truncate(Limb, w_value); |
| 241 | | 241 | w_value >>= limb_bits; |
| 242 | // TODO: shift == 64 at compile-time fails. Fails on u128 limbs. | | |
| 243 | w_value >>= limb_bits / 2; | | |
| 244 | w_value >>= limb_bits / 2; | | |
| 245 | | 242 | |
| 246 | if (w_value == 0) break; | 243 | if (w_value == 0) break; |
| 247 | } | 244 | } |
| ... | @@ -258,9 +255,7 @@ pub const Mutable = struct { | ... | @@ -258,9 +255,7 @@ pub const Mutable = struct { |
| 258 | comptime var i = 0; | 255 | comptime var i = 0; |
| 259 | inline while (true) : (i += 1) { | 256 | inline while (true) : (i += 1) { |
| 260 | self.limbs[i] = w_value & mask; | 257 | self.limbs[i] = w_value & mask; |
| 261 | | 258 | w_value >>= limb_bits; |
| 262 | w_value >>= limb_bits / 2; | | |
| 263 | w_value >>= limb_bits / 2; | | |
| 264 | | 259 | |
| 265 | if (w_value == 0) break; | 260 | if (w_value == 0) break; |
| 266 | } | 261 | } |