Zig 0.17.0-dev (Split by item) This is an example of documentation generated by
ZigDoc , an alternative to Zig's built-in
Auto Doc feature. See also
examples in other modes/formats . The project being documented here (as the example) is the Zig standard library.
std › crypto › ff › Modulus › add Public Function add Doc Source Public Function std.crypto.ff.Modulus.add
pub fn add (self : Self , x : Fe , y : Fe ) Fe Params File crypto/ff.zig: 538
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560 pub fn add (self : Self , x : Fe , y : Fe ) Fe {
var out = x ;
if (x .montgomery == y .montgomery ) {
@branchHint (.likely );
const overflow = out .v .addWithOverflow (y .v );
const underflow : u1 = @bitCast (ct .limbsCmpLt (out .v , self .v ));
const need_sub = ct .eql (overflow , underflow );
_ = out .v .conditionalSubWithOverflow (need_sub , self .v );
return out ;
} else {
var y_ = y ;
if (y .montgomery ) {
self .fromMontgomery (&y_ ) catch unreachable ;
} else {
self .toMontgomery (&y_ ) catch unreachable ;
}
const overflow = out .v .addWithOverflow (y_ .v );
const underflow : u1 = @bitCast (ct .limbsCmpLt (out .v , self .v ));
const need_sub = ct .eql (overflow , underflow );
_ = out .v .conditionalSubWithOverflow (need_sub , self .v );
return out ;
}
}
Adds two field elements (mod m).