This package contains implementation of the library "Apfloat". Apfloat is a data type supporting arbitrary-precision numbers.
Project description
Apfloat
Apfloat is an arbitrary precision number library which supports numbers with any values and many operations with them.
Installation
pip install Apfloat
Usage
To use the library install it using the command shown in "Installation" section. Then, read the instructions below regarding how to use operations with Apfloat.
Addition
Addition of Apfloat objects can be implemented using the '+' operator.
Input: Apfloat("5.12") + Apfloat("6.13") Output: Apfloat("11.25")
Subtraction
Subtraction of Apfloat objects can be implemented using the '-' operator.
Input: Apfloat("7.22") - Apfloat("6.13") Output: Apfloat("1.09")
Multiplication
Multiplication of Apfloat objects can be implemented using the '*' operator.
Input: Apfloat("5") * Apfloat("3") Output: Apfloat("15")
Division
Division of Apfloat objects can be implemented using the '/' operator.
Input: Apfloat("5") / Apfloat("2") Output: Apfloat("2.5")
Integer Division
Integer Division of Apfloat objects can be implemented using the '/' operator.
Input: Apfloat("5") // Apfloat("2") Output: Apfloat("2")
Power
Power of Apfloat objects can be implemented using the '**' operator.
Input: Apfloat("5") ** Apfloat("2") Output: Apfloat("25")
Modulo
Modulo of Apfloat objects can be implemented using the '%' operator.
Input: Apfloat("5") % Apfloat("2") Output: Apfloat("1")
Convert to Integer
Input: int(Apfloat("5.33")) Output: 5
Convert to Float
Input: float(Apfloat("5.00")) Output: ~5.00
Convert to mpf
Input: mpf(Apfloat("5.00")) Output: mpf("5.00")
Square
Input: Apfloat("3").squared() Output: Apfloat("9")
Cube
Input: Apfloat("3").cubed() Output: Apfloat("27")
Trigonometric Functions
sin, cos, tan, cosec, sec, and cot are usable trigonometric functions. They are called using the code with the format {trigonometric function name}(a big number object). For example, sin(Apfloat("0.5")) to get the value of sin(0.5).
Hyperbolic Functions
sinh, cosh, tanh, cosech, sech, and coth are usable hyperbolic functions. They are called using the code with the format {hyperbolic function name}(a big number object). For example, sinh(Apfloat("0.5")) to get the value of sinh(0.5).
Factorial
The function factorial(apfloat: Apfloat) will quickly get the factorial of any number.
Input: factorial(Apfloat("6")) Output: Apfloat("720")
Logarithms
The logarithm of any number using any base can be quickly achieved by using the function log_base(apfloat: MPComplex, base: MPComplex or mpf or float or int) where apfloat is an MPComplex object and base is the base used for the logarithm operation.
Square Root
sqrt(apfloat: Apfloat) gets the square root of any number.
Input: sqrt(Apfloat("81")) Output: Apfloat("9")
Cube Root
cbrt(apfloat: Apfloat) gets the cube root of any number.
Input: cbrt(Apfloat("27")) Output: Apfloat("3")
Checking for Prime Numbers
is_prime(apfloat: Apfloat) checks whether a number is prime or not.
Input: is_prime(Apfloat("7")) Output: True
Getting GCD of Two Numbers
gcd(a: Apfloat, b: Apfloat) gets the GCD of numbers a and b.
Input: gcd(Apfloat("12"), Apfloat("8")) Output: Apfloat("4")
Getting LCM of Two Numbers
lcm(a: Apfloat, b: Apfloat) gets the LCM of numbers a and b.
Input: lcm(Apfloat("6"), Apfloat("8")) Output: Apfloat("24")
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file Apfloat-1.1.tar.gz
.
File metadata
- Download URL: Apfloat-1.1.tar.gz
- Upload date:
- Size: 4.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.7.1 importlib_metadata/4.10.0 pkginfo/1.8.2 requests/2.27.1 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.9.4
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 98ed6d8f14536561f883db3529b92d50c7dad037851e5f92c6b7ee67825e32e4 |
|
MD5 | d76ab4f7285b709a477345d37fb2d280 |
|
BLAKE2b-256 | a662575be598758e97886c6e1a20c555df6aab697857c1f78ef3e3b94226ac42 |
File details
Details for the file Apfloat-1.1-py2-none-any.whl
.
File metadata
- Download URL: Apfloat-1.1-py2-none-any.whl
- Upload date:
- Size: 6.1 kB
- Tags: Python 2
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.7.1 importlib_metadata/4.10.0 pkginfo/1.8.2 requests/2.27.1 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.9.4
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | bf2818aff8b8740342e27ec01f592f0880cc9fef742ab5a6ef34137ddd0f9153 |
|
MD5 | c666c7a64ad905895d29ba47a9db8f76 |
|
BLAKE2b-256 | f3817fbd942a65fe8464ffa5011c5575ee7f3a4ca2eaef79ff2bae05e921bef6 |