]> git.lizzy.rs Git - plan9front.git/blobdiff - sys/man/2/mp
fix bugs and cleanup cryptsetup code
[plan9front.git] / sys / man / 2 / mp
index c562ccab42f6aea9301e9e7e190cb1d2fee29805..678f0eb7fd883c5b7c1a41076eaada712a5f7bd6 100644 (file)
@@ -106,6 +106,30 @@ void       mpleft(mpint *b, int shift, mpint *res)
 void   mpright(mpint *b, int shift, mpint *res)
 .PP
 .B
+void   mpand(mpint *b1, mpint *b2, mpint *res)
+.PP
+.B
+void   mpbic(mpint *b1, mpint *b2, mpint *res)
+.PP
+.B
+void   mpor(mpint *b1, mpint *b2, mpint *res)
+.PP
+.B
+void   mpnot(mpint *b, mpint *res)
+.PP
+.B
+void   mpxor(mpint *b1, mpint *b2, mpint *res)
+.PP
+.B
+void   mptrunc(mpint *b, int n, mpint *res)
+.PP
+.B
+void   mpxtend(mpint *b, int n, mpint *res)
+.PP
+.B
+void   mpasr(mpint *b, int n, mpint *res)
+.PP
+.B
 void   mpmul(mpint *b1, mpint *b2, mpint *prod)
 .PP
 .B
@@ -337,13 +361,22 @@ convert between
 and
 .B mpint
 representations using the base indicated.
-Only the bases 10, 16, 32, and 64 are
-supported.  Anything else defaults to 16.
+Only the bases 2, 4, 8, 10, 16, 32, and 64 are
+supported.  Base 0 defaults to 16.
 .IR Strtomp
 skips any leading spaces or tabs.
 .IR Strtomp 's
 scan stops when encountering a digit not valid in the
 base.  If
+.I base
+is zero then C-style prefixes are interpreted to
+find the base:
+.B 0x
+for hexadecimal,
+.B 0b
+for binary and
+.B 0
+for octal. Otherwise decimal is assumed.
 .I rptr
 is not zero,
 .I *rptr
@@ -536,6 +569,48 @@ is assigned to
 .IR res .
 .PD
 .PP
+Logical operations (treating negative numbers using two's complement):
+.TF mpxtend_
+.TP
+.I mpand
+.BR "res = b1 & b2" .
+.TP
+.I mpbic
+.BR "res = b1 & ~b2" .
+.TP
+.I mpor
+.BR "res = b1 | b2" .
+.TP
+.I mpxor
+.BR "res = b1 ^ b2" .
+.TP
+.I mpnot
+.BR "res = ~b1" .
+.TP
+.I mpasr
+.BR "res = b>>shift"
+(\fImpasr\fR, unlike
+.IR mpright ,
+uses two's complement).
+.TP
+.I mptrunc
+truncates
+.I b
+to 
+.I n
+bits and stores the result in
+.IR res .
+The result is never negative.
+.TP
+.I mpxtend
+truncates
+.I b
+to
+.I n
+bits, sign extends the MSB and stores the result in
+.IR res .
+.PD
+.PP
 Modular arithmetic:
 .TF mpmodmul_
 .TP