Arbitrary-precision integers (included): Difference between revisions

m
(→‎{{header|Raku}}: use regex)
Tag: Made through Tor
Line 2,487:
=={{header|Zig}}==
<syntaxhighlight lang="zig">const std = @import("std");
const std = @import("std");
const bigint = std.math.big.int.Managed;
 
pub fn main() !void {
var gpaa = try bigint.initSet(std.heap.GeneralPurposeAllocator(.{}c_allocator, 5){};
try a.pow(&a.toConst(), try std.math.powi(u32, 4, try std.math.powi(u32, 3, 2)));
const allocator = &gpa.allocator;
defer _ = gpa.deinit();
 
var a = try bigint.initSet(allocator, 5);
try a.pow(a.toConst(), try std.math.powi(u32, 4, try std.math.powi(u32, 3, 2)));
defer a.deinit();
 
var as = try a.toString(allocatorstd.heap.c_allocator, 10, false.lower);
defer allocatorstd.heap.c_allocator.free(as);
 
std.debug.print("{s}...{s}\n", .{ as[0..20], as[as.len - 20 ..] });
3

edits