-
Notifications
You must be signed in to change notification settings - Fork 4
The math big library
The big library implements arbitrary-precision arithmetic (big numbers).
The big float type.
The big rational type.
Constructs a Float from a float.
Constructs a Float from a string.
Constructs a Float from a Rat.
Adds two Float values.
Subtracts one Float value from another.
Multiplies two Float values.
Divides one Float value by another.
Negates a Float value.
Compares two Float values, returning true if x < y.
Compares two Float values, returning true if x <= y.
Compares two Float values, returning true if x > y.
Compares two Float values, returning true if x >= y.
Returns the absolute value of a Float.
Converts a Float to the built-in float type.
Converts a Float to the built-in int type.
Tests whether the given Float is an infinity.
Tests whether the given Float is an integer.
sign(z) returns:
-
-1ifz < 0 -
0ifz == 0 -
1ifz > 0
Returns the square root of a Float.
Overloads string.
Converts the Float to a string of the given format and precision.
Constructs an Int from an int.
Constructs an Int from a string.
Constructs an Int from a Float.
Adds two Int values.
Subtracts one Int value from another.
Multiplies two Int values.
Negates an Int.
x / y returns the Rat obtained by dividing x by y.
x div y returns the Int obtained by dividing x by y.
Returns the modulus of one Int by another.
Returns the exponent of on Int by another.
Compares two Int values and returns true if x < y.
Compares two Int values and returns true if x <= y.
Compares two Int values and returns true if x > y.
Compares two Int values and returns true if x >= y.
Returns the absolute value of an Int.
Returns the result of a bitwise and operation on two Ints.
Returns the result of a bitwise and not operation on two Ints.
Returns the binomial coefficient C(n, k).
Returns the value of the ith bit of the Int, as 0 or 1.
Returns the length of the absolute value of x in bits. The bit length of 0 is 0.
divMod(x, y) returns the quotient and modulus of x by y.
Returns x to the power y mod abs(m). If m == 0, z = x**y unless y <= 0, when z = 1. If m != 0, y < 0, and x and m are not relatively prime, z is unchanged and nil is returned. Modular exponentiation of inputs of a particular size is not a cryptographically constant-time operation.
Converts an Int to the built-in float type.
Converts a string in the given base to an Int, returning an error if the string isn't well-formed.
Returns the greatest common denominator of two Ints.
Converts an Int to the built-in int type.
Returns true if the given Int will fit into a built-in (64-bit) int.
Returns the result of a bitwise left shift of x by n bits.
Returns the inverse of g mod n.
Returns a square root of x mod p.
Returns the result of multiplying the numbers in the range a::b.
Resturns the result of performing a bitwise not on an Int.
Returns the result of a bitwise or operation on two Ints.
probablyPrime reports whether x is probably prime, applying the Miller-Rabin test with n pseudorandomly chosen bases as well as a Baillie-PSW test.
If x is prime, ProbablyPrime returns true. If x is chosen randomly and not prime, probablyPrime probably returns false. The probability of returning true for a randomly chosen non-prime is at most ¼ⁿ.
ProbablyPrime is 100% accurate for inputs less than 2⁶⁴. See Menezes et al., Handbook of Applied Cryptography, 1997, pp. 145-149, and FIPS 186-4 Appendix F for further discussion of the error probabilities.
ProbablyPrime is not suitable for judging primes that an adversary may have crafted to fool the test.
Returns the quotient of x by y using truncated division.
Returns the quotient and remainder of x by y using truncated division.
Returns the remainder when dividing x by y using truncated division.
Returns the result of a bitwise left shift of x by n bits.
sign(z) returns:
-
-1ifz < 0 -
0ifz == 0 -
1ifz > 0
Returns ⌊√x⌋, the largest integer such that z² ≤ x.
Overloads string.
text returns the string representation of x in the given base. Base must be between 2 and 62, inclusive. The result uses the lower-case letters 'a' to 'z' for digit values 10 to 35, and the upper-case letters 'A' to 'Z' for digit values 36 to 61. No prefix (such as "0x") is added to the string.
Returns the number of consecutive least significant zero bits of |x|.
Returns the result of a bitwise xor operation on two Ints.
Constructs a Rat from two ints.
Constructs a Rat from a Float.
Constructs a Rat from a string.
Converts the built-in float type to a Rat.
Converts two Ints to the Rat which is their quotient.
Converts an Int to its representation as a Rat.
Converts an int to its representation as a Rat.
Adds two Rat values.
Subtracts one Rat value from another.
Multiplies two Rat values.
Divides one Rat value by another.
Negates a Rat value.
Compares two Rat values and returns true if x < y.
Compares two Rat values and returns true if x <= y.
Compares two Rat values and returns true if x > y.
Compares two Rat values and returns true if x >= y.
Returns the abolute value of z.
Returns the denominator of z.
Converts a Rat to a built-in float value.
Returns a string representation of x in decimal form with prec digits of precision after the radix point. The last digit is rounded to nearest, with halves rounded away from zero.
Returns the inverse of a Rat.
Tests whether z represents an integer.
Returns the numerator of a Rat.
Returns a string representation of z in the form "a/b" if b != 1, and in the form "a" if b == 1.
sign(z) returns:
-
-1ifz < 0 -
0ifz == 0 -
1ifz > 0
Returns a string representation of z in the form "a/b" (even if b == 1).
This page is automatically generated from the Pipefish standard library. Any edits made directly to this wiki page will be overwritten the next time the documentation is regenerated.
🧿 Pipefish is distributed under the MIT license. Please steal my code and ideas.
- Getting started
- Language basics
- The type system and built-in functions
- Functional Pipefish
- Encapsulation
- Imperative Pipefish
-
Imports and libraries
- The crypto/aes library
- The crypto/bcrypt library
- The crypto/rand library
- The crypto/rsa library
- The crypto/sha_256 library
- The crypto/sha_512 library
- The database/sql library
- The encoding/base_32 library
- The encoding/base_64 library
- The encoding/csv library
- The encoding/json library
- The files library
- The fmt library
- The html library
- The image library
- The image/bmp library
- The image/color library
- The image/jpeg library
- The image/png library
- The lists library
- The markdown library
- The math library
- The math/big library
- The math/cmplx library
- The math/rand library
- The net/http library
- The net/mail library
- The net/smtp library
- The net/url library
- The os/exec library
- The path library
- The path/filepath library
- The reflect library
- The regexp library
- The strconv library
- The strings library
- The terminal library
- The time library
- The unicode library
- Advanced Pipefish
- Developing in Pipefish
- Deployment
- Appendices