Tracking Issue for bigint helper methods · Issue #85532 · rust-lang/rust (original) (raw)

Feature gate: #![feature(bigint_helper_methods)]

This is a tracking issue for the following methods on integers:

These methods are intended to help centralise the effort required for creating efficient big integer implementations, by offering a few methods which would otherwise require special compiler intrinsics or custom assembly code in order to do efficiently. They do not alone constitute big integer implementations themselves, but are necessary building blocks for a larger implementation.

Public API

// On unsigned integers:

/// self + rhs + carry (full adder) const fn carrying_add(self, rhs: Self, carry: bool) -> (Self, bool);

/// self - rhs - carry (full "subtractor") const fn borrowing_sub(self, rhs: Self, carry: bool) -> (Self, bool);

/// self * rhs + carry (multiply-accumulate) const fn carrying_mul(self, rhs: Self, carry: Self) -> (Self, Self);

/// self * rhs + carry (multiply-accumulate-carry) const fn carrying_mul_add(self, rhs: Self, addend: Self, carry: Self) -> (Self, Self);

/// self * rhs (wide multiplication, same as self.carrying_mul(rhs, 0)) const fn widening_mul(self, rhs: Self) -> (Self, Self);

// On signed integers:

/// self + rhs + carry (full adder) const fn carrying_add(self, rhs: Self, carry: bool) -> (Self, bool);

/// self - rhs - carry (full "subtractor") const fn borrowing_sub(self, rhs: Self, carry: bool) -> (Self, bool);

Steps / History

Unresolved Questions