Function setString [src]
Set self from the string representation value.
value must contain only digits <= base and is case insensitive. Base prefixes are
not allowed (e.g. 0x43 should simply be 43). Underscores in the input string are
ignored and can be used as digit separators.
Returns an error if memory could not be allocated or value has invalid digits for the
requested base.
self's allocator is used for temporary storage to boost multiplication performance.
Prototype
pub fn setString(self: *Managed, base: u8, value: []const u8) !void
Parameters
self: *Managed
base: u8
value: []const u8
Source
pub fn setString(self: *Managed, base: u8, value: []const u8) !void {
if (base < 2 or base > 36) return error.InvalidBase;
try self.ensureCapacity(calcSetStringLimbCount(base, value.len));
const limbs_buffer = try self.allocator.alloc(Limb, calcSetStringLimbsBufferLen(base, value.len));
defer self.allocator.free(limbs_buffer);
var m = self.toMutable();
try m.setString(base, value, limbs_buffer, self.allocator);
self.setMetadata(m.positive, m.len);
}