Skip to main content

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")

Release files for Apfloat 1.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for Apfloat 1.1
File Size Uploaded
Apfloat-1.1.tar.gz 4.7 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for Apfloat 1.1
File Interpreter ABI Platform
Apfloat-1.1-py2-none-any.whl Python 2 none any Details

Total release size: 10.8 kB

Release files / Apfloat-1.1.tar.gz

Download URL Apfloat-1.1.tar.gz
Size 4.7 kB
Tags Source
SHA-256 checksum
How to use checksums
98ed6d8f14536561f883db3529b92d50c7dad037851e5f92c6b7ee67825e32e4
BLAKE2b-256 checksum
How to use checksums
a662575be598758e97886c6e1a20c555df6aab697857c1f78ef3e3b94226ac42
Upload date
Uploaded using Trusted Publishing?
What is 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

Release files / Apfloat-1.1-py2-none-any.whl

Download URL Apfloat-1.1-py2-none-any.whl
Size 6.1 kB
Tags Python 2
SHA-256 checksum
How to use checksums
bf2818aff8b8740342e27ec01f592f0880cc9fef742ab5a6ef34137ddd0f9153
BLAKE2b-256 checksum
How to use checksums
f3817fbd942a65fe8464ffa5011c5575ee7f3a4ca2eaef79ff2bae05e921bef6
Upload date
Uploaded using Trusted Publishing?
What is 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

Release history Release notifications | RSS feed

This release

1.1 This release

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page