Skip to content

Instantly share code, notes, and snippets.

@joelonsql
Created December 23, 2022 13:40
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save joelonsql/7d5f8c664c9a33c7acf0db7d8958bccd to your computer and use it in GitHub Desktop.
Save joelonsql/7d5f8c664c9a33c7acf0db7d8958bccd to your computer and use it in GitHub Desktop.
const std = @import("std");
const bigint = std.math.big.int.Managed;
pub fn main() !void {
var a = try bigint.initSet(std.heap.c_allocator, 5);
try a.pow(&a, try std.math.powi(u32, 4, try std.math.powi(u32, 3, 2)));
defer a.deinit();
var as = try a.toString(std.heap.c_allocator, 10, .lower);
defer std.heap.c_allocator.free(as);
std.debug.print("{s}...{s}\n", .{ as[0..20], as[as.len - 20 ..] });
std.debug.print("{} digits\n", .{as.len});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment