Skip to content

Commit

Permalink
std/math/big: improve documentation of the Int
Browse files Browse the repository at this point in the history
  • Loading branch information
mertcandav committed Oct 23, 2024
1 parent 1b54518 commit 578ea85
Showing 1 changed file with 21 additions and 1 deletion.
22 changes: 21 additions & 1 deletion std/math/big/int.jule
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,27 @@ use "std/unsafe"
static mut intZero = Int{}
static mut intOne = Int{abs: wordOne}

// Arbitrary big integer.
// An Int represents a signed multi-precision integer.
// The zero value for an Int represents the value 0.
//
// Copying is completely safe and there is no additional allocation cost.
// A common buffer is used within the scope of interior mutability.
// The value returned as a result of any calculation must be independent of the
// parameters taken or must not change it. Therefore, even a simple addition or
// subtraction operation can realize a new internal allocation.
// Some methods may continue to use common allocation without any changes
// if possible, but this is not a guarantee. This implementation cares adhering to
// Jule's mechanics, such as immutability, and keeping side effects on common buffers
// as minimal as possible. If more control over common allocations is required at
// the expense of ignoring that points, this implementation may not be a good choice.
//
// Note that methods may leak the Int's value through timing side-channels.
// Because of this and because of the scope and complexity of the
// implementation, Int is not well-suited to implement cryptographic operations.
// The standard library avoids exposing non-trivial Int methods to
// attacker-controlled inputs and the determination of whether a bug in std/math/big
// is considered a security vulnerability might depend on the impact on the
// standard library.
struct Int {
mut abs: []Word
mut neg: bool
Expand Down

0 comments on commit 578ea85

Please sign in to comment.