tiehuis / zig-bn

big numbers for zig

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

This is now merged into the zig stdlib.

An arbitrary precision big integer library for zig.

The interface is akin to that of GMP.

const std = @import("std");
const ArenaAllocator = std.heap.ArenaAllocator;

const BigInt = @import("bigint.zig").BigInt;

pub fn main() !void {
    const arena = ArenaAllocator.init(std.debug.global_allocator);
    defer arena.deinit();
    var al = arena.allocator;

    var a = try BigInt.init(al);
    var b = try BigInt.init(al);

    try a.set(1990273423429836742364234234234);
    try b.set(1990273423429836742364234234234);

    try a.add(&a, &b);
    try a.mul(&a, &b);

    try a.mul(&a, 14343);
}

About

big numbers for zig

License:MIT License


Languages

Language:Zig 92.2%Language:Makefile 3.7%Language:Rust 1.2%Language:C 1.1%Language:Go 1.0%Language:Python 0.8%