Arithmetic | Science @ Science @ MentDB Weak
Arithmetic and precision
• Exact arithmetic: integers of any size and fractions.
• The fractions use the format p/q: "3/4", "-1/2". A decimal is converted exactly (0.5 = 1/2).
• is_prime is deterministic up to 2^63, and probabilistic above (error probability < 2^-100).
• Decimal computation with a chosen precision (BigDecimal): no binary rounding (0.1 + 0.2 = 0.3).
• precision = number of significant digits (1 to 10000), scale = number of decimals.
• Rounding modes: HALF_UP (default), HALF_EVEN, HALF_DOWN, UP, DOWN, CEILING, FLOOR.
• The operators bd+ bd- bd* bd/ are also available: bd/ gives 34 significant digits when the quotient is not finite (1/3).
• The fractions use the format p/q: "3/4", "-1/2". A decimal is converted exactly (0.5 = 1/2).
• is_prime is deterministic up to 2^63, and probabilistic above (error probability < 2^-100).
• Decimal computation with a chosen precision (BigDecimal): no binary rounding (0.1 + 0.2 = 0.3).
• precision = number of significant digits (1 to 10000), scale = number of decimals.
• Rounding modes: HALF_UP (default), HALF_EVEN, HALF_DOWN, UP, DOWN, CEILING, FLOOR.
• The operators bd+ bd- bd* bd/ are also available: bd/ gives 34 significant digits when the quotient is not finite (1/3).
arith factorial arith factors arith frac_add arith frac_div arith frac_mul arith frac_sub arith gcd arith gcd arith iquo arith irem arith is_prime arith lcm arith lcm arith ncr arith next_prime arith npr arith to_fraction arith divisors arith invmod arith isqrt arith phi arith powmod bigdec abs bigdec compare bigdec div bigdec div bigdec negate bigdec pow bigdec precision bigdec precision bigdec round bigdec round bigdec sqrt bigdec strip bigdec e bigdec mean bigdec pi bigdec sum
arith factorial <n>
Description
Get n! (exact, n <= 20000)
Get n! (exact, n <= 20000)
Parameters
n: An integer >= 0 - Number - required
n: An integer >= 0 - Number - required
Examples (5)
admin
arith factorial 25
mentdb
15511210043330985984000000
50! exactly
admin
arith factorial 50
mentdb
30414093201713378043612608166064768844377641568960512000000000000
0! = 1
admin
arith factorial 0
mentdb
1
Exact value of 100!
admin
arith factorial 100
mentdb
93326215443944152681699238856266700490715968264381621468592963895217599993229915608941463976156518286253697920827223758251185210916864000000000000000000000000
Number of orders of a deck of 52 cards
admin
arith factorial 52
mentdb
80658175170943878571660636856403766975289505440883277824000000000000
arith factors <n>
Description
Get the prime factors (JSON array, with repetition). Pollard rho method: numbers up to about 60 digits.
Get the prime factors (JSON array, with repetition). Pollard rho method: numbers up to about 60 digits.
Parameters
n: An integer >= 2 - Number - required
n: An integer >= 2 - Number - required
Examples (6)
admin
arith factors 360
mentdb
[2,2,2,3,3,5]
admin
arith factors 18446744073709551617
mentdb
[274177,67280421310721]
A large number
admin
arith factors 1234567890
mentdb
[2,3,3,5,3607,3803]
Prime number
admin
arith factors 97
mentdb
[97]
Power of 2
admin
arith factors 1024
mentdb
[2,2,2,2,2,2,2,2,2,2]
Product of two large primes
admin
arith factors 600851475143
mentdb
[71,839,1471,6857]
arith frac_add <a> <b>
Description
Add two fractions (exact)
Add two fractions (exact)
Parameters
a: A fraction p/q, an integer or a decimal - String - required
b: A fraction p/q, an integer or a decimal - String - required
a: A fraction p/q, an integer or a decimal - String - required
b: A fraction p/q, an integer or a decimal - String - required
Examples (5)
admin
arith frac_add "1/3" "1/6"
mentdb
1/2
admin
arith frac_add 0.5 "1/3"
mentdb
5/6
Sum of three fractions
admin
arith frac_add (arith frac_add "1/2" "1/3") "1/6"
mentdb
1
Negative fractions
admin
arith frac_add "-1/4" "1/6"
mentdb
-1/12
Integers and fractions
admin
arith frac_add 2 "3/5"
mentdb
13/5
arith frac_div <a> <b>
Description
Divide two fractions (exact)
Divide two fractions (exact)
Parameters
a: A fraction p/q, an integer or a decimal - String - required
b: A fraction p/q, an integer or a decimal - String - required
a: A fraction p/q, an integer or a decimal - String - required
b: A fraction p/q, an integer or a decimal - String - required
Examples (4)
admin
arith frac_div "1/2" "1/4"
mentdb
2
Division by an integer
admin
arith frac_div "3/4" 3
mentdb
1/4
Negative fraction
admin
arith frac_div "-2/3" "4/9"
mentdb
-3/2
Division by 0: error
admin
arith frac_div "1/2" 0
mentdb
Sorry, an error appears (division by zero).
arith frac_mul <a> <b>
Description
Multiply two fractions (exact)
Multiply two fractions (exact)
Parameters
a: A fraction p/q, an integer or a decimal - String - required
b: A fraction p/q, an integer or a decimal - String - required
a: A fraction p/q, an integer or a decimal - String - required
b: A fraction p/q, an integer or a decimal - String - required
Examples (4)
admin
arith frac_mul "2/3" "9/4"
mentdb
3/2
Simplification
admin
arith frac_mul "4/6" "3/8"
mentdb
1/4
By an integer
admin
arith frac_mul "5/12" 6
mentdb
5/2
Recipe for 6 people from a recipe for 4: 3/4 cup x 6/4
admin
arith frac_mul "3/4" "6/4"
mentdb
9/8
arith frac_sub <a> <b>
Description
Subtract two fractions (exact)
Subtract two fractions (exact)
Parameters
a: A fraction p/q, an integer or a decimal - String - required
b: A fraction p/q, an integer or a decimal - String - required
a: A fraction p/q, an integer or a decimal - String - required
b: A fraction p/q, an integer or a decimal - String - required
Examples (3)
admin
arith frac_sub "1/2" "3/4"
mentdb
-1/4
Same fraction: 0
admin
arith frac_sub "2/3" "4/6"
mentdb
0
Integer minus a fraction
admin
arith frac_sub 1 "5/8"
mentdb
3/8
arith gcd <a> <b>
Description
Get the greatest common divisor of two integers
Get the greatest common divisor of two integers
Parameters
a: An integer - Number - required
b: An integer - Number - required
a: An integer - Number - required
b: An integer - Number - required
Examples (5)
admin
arith gcd 48 180
mentdb
12
Large numbers
admin
arith gcd 1071 462
mentdb
21
Coprime numbers: 1
admin
arith gcd 35 64
mentdb
1
Simplify 84/126
admin
arith gcd 84 126
mentdb
42
Large integers
admin
arith gcd 123456789012345678 987654321098765432
mentdb
2
arith gcd <json_array>
Description
Get the greatest common divisor of a list of integers
Get the greatest common divisor of a list of integers
Parameters
json_array: A JSON array of integers - String - required
json_array: A JSON array of integers - String - required
Examples (3)
admin
arith gcd "[12, 18, 30]"
mentdb
6
Gear teeth
admin
arith gcd "[24, 36, 60, 84]"
mentdb
12
Coprime numbers
admin
arith gcd "[6, 10, 15]"
mentdb
1
arith iquo <a> <b>
Description
Get the quotient of the Euclidean division: a = b.q + r with 0 <= r < |b|
Get the quotient of the Euclidean division: a = b.q + r with 0 <= r < |b|
Parameters
a: An integer - Number - required
b: An integer (not 0) - Number - required
a: An integer - Number - required
b: An integer (not 0) - Number - required
Examples (4)
admin
arith iquo 17 5
mentdb
3
admin
arith iquo -17 5
mentdb
-4
Weeks in 100 days
admin
arith iquo 100 7
mentdb
14
Division by 0: error
admin
arith iquo 10 0
mentdb
Sorry, an error appears (division by zero).
arith irem <a> <b>
Description
Get the remainder of the Euclidean division (always >= 0, unlike 'math mod')
Get the remainder of the Euclidean division (always >= 0, unlike 'math mod')
Parameters
a: An integer - Number - required
b: An integer (not 0) - Number - required
a: An integer - Number - required
b: An integer (not 0) - Number - required
Examples (4)
admin
arith irem 17 5
mentdb
2
admin
arith irem -17 5
mentdb
3
Day of the week 100 days after a Monday (0 = Monday)
admin
arith irem 100 7
mentdb
2
Divisible: 0
admin
arith irem 144 12
mentdb
0
arith is_prime <n>
Description
Check if an integer is prime (1 or 0)
Check if an integer is prime (1 or 0)
Parameters
n: An integer (any size) - Number - required
n: An integer (any size) - Number - required
Examples (6)
admin
arith is_prime 97
mentdb
1
A large prime number (Mersenne 2^61 - 1)
admin
arith is_prime 2305843009213693951
mentdb
1
A composite number
admin
arith is_prime 1001
mentdb
0
2 is prime
admin
arith is_prime 2
mentdb
1
1 is not prime
admin
arith is_prime 1
mentdb
0
Mersenne number 2^31 - 1
admin
arith is_prime 2147483647
mentdb
1
arith lcm <a> <b>
Description
Get the least common multiple of two integers
Get the least common multiple of two integers
Parameters
a: An integer - Number - required
b: An integer - Number - required
a: An integer - Number - required
b: An integer - Number - required
Examples (3)
admin
arith lcm 4 6
mentdb
12
Two periods: when do they meet again?
admin
arith lcm 12 18
mentdb
36
Coprime numbers: the product
admin
arith lcm 7 9
mentdb
63
arith lcm <json_array>
Description
Get the least common multiple of a list of integers
Get the least common multiple of a list of integers
Parameters
json_array: A JSON array of integers - String - required
json_array: A JSON array of integers - String - required
Examples (3)
admin
arith lcm "[2, 3, 4, 5]"
mentdb
60
Common denominator of 1/4, 1/6 and 1/10
admin
arith lcm "[4, 6, 10]"
mentdb
60
Numbers 1 to 10
admin
arith lcm "[1, 2, 3, 4, 5, 6, 7, 8, 9, 10]"
mentdb
2520
arith ncr <n> <k>
Description
Get the number of combinations C(n, k) (exact)
Get the number of combinations C(n, k) (exact)
Parameters
n: An integer >= 0 - Number - required
k: An integer >= 0 - Number - required
n: An integer >= 0 - Number - required
k: An integer >= 0 - Number - required
Examples (5)
admin
arith ncr 100 50
mentdb
100891344545564193334812497256
Lottery: 6 numbers among 49
admin
arith ncr 49 6
mentdb
13983816
C(n, 0) = 1
admin
arith ncr 10 0
mentdb
1
Symmetry: C(10, 3) = C(10, 7)
admin
arith ncr 10 7
mentdb
120
Hands of 5 cards among 52
admin
arith ncr 52 5
mentdb
2598960
arith next_prime <n>
Description
Get the smallest prime number strictly greater than n
Get the smallest prime number strictly greater than n
Parameters
n: An integer (any size) - Number - required
n: An integer (any size) - Number - required
Examples (4)
admin
arith next_prime 13
mentdb
17
After 1000
admin
arith next_prime 1000
mentdb
1009
After a prime number: the next one
admin
arith next_prime 97
mentdb
101
Large number
admin
arith next_prime 1000000000000
mentdb
1000000000039
arith npr <n> <k>
Description
Get the number of arrangements A(n, k) = n!/(n-k)! (exact)
Get the number of arrangements A(n, k) = n!/(n-k)! (exact)
Parameters
n: An integer >= 0 - Number - required
k: An integer >= 0 - Number - required
n: An integer >= 0 - Number - required
k: An integer >= 0 - Number - required
Examples (4)
admin
arith npr 5 2
mentdb
20
Podium of 3 among 10 runners
admin
arith npr 10 3
mentdb
720
All the orders of 5 objects: 5!
admin
arith npr 5 5
mentdb
120
Codes of 4 different digits
admin
arith npr 10 4
mentdb
5040
arith to_fraction <x>
Description
Convert a number to a fraction.
- A fraction is reduced: 6/8 -> 3/4.
- A decimal with less than 10 significant digits is converted exactly: 0.33 -> 33/100.
- A decimal with 10 significant digits or more is considered as a rounded result: the first convergent of its continued fraction within max(half a unit of the last digit, 1e-12 relative) is returned.
Convert a number to a fraction.
- A fraction is reduced: 6/8 -> 3/4.
- A decimal with less than 10 significant digits is converted exactly: 0.33 -> 33/100.
- A decimal with 10 significant digits or more is considered as a rounded result: the first convergent of its continued fraction within max(half a unit of the last digit, 1e-12 relative) is returned.
Parameters
x: A decimal number or a fraction - String - required
x: A decimal number or a fraction - String - required
Examples (7)
admin
arith to_fraction 0.75
mentdb
3/4
admin
arith to_fraction 0.30000000000000004
mentdb
3/10
Repeating decimal
admin
arith to_fraction 0.3333333333333333
mentdb
1/3
Approximation of pi
admin
arith to_fraction 3.14159
mentdb
314159/100000
Negative number
admin
arith to_fraction -0.125
mentdb
-1/8
Integer
admin
arith to_fraction 3
mentdb
3
Decimal with many digits
admin
arith to_fraction 0.142857
mentdb
142857/1000000
arith divisors <n>
Description
Get all the positive divisors (sorted JSON array)
Get all the positive divisors (sorted JSON array)
Parameters
n: An integer >= 1 - Number - required
n: An integer >= 1 - Number - required
Examples (4)
admin
arith divisors 360
mentdb
[1,2,3,4,5,6,8,9,10,12,15,18,20,24,30,36,40,45,60,72,90,120,180,360]
Divisors of 28 (a perfect number)
admin
arith divisors 28
mentdb
[1,2,4,7,14,28]
Prime number
admin
arith divisors 13
mentdb
[1,13]
Square number
admin
arith divisors 36
mentdb
[1,2,3,4,6,9,12,18,36]
arith invmod <a> <m>
Description
Get the modular inverse of a modulo m (error if gcd(a, m) > 1)
Get the modular inverse of a modulo m (error if gcd(a, m) > 1)
Parameters
a: An integer - Number - required
m: The modulus (> 0) - Number - required
a: An integer - Number - required
m: The modulus (> 0) - Number - required
Examples (4)
admin
arith invmod 3 11
mentdb
4
7 x 103 = 1 (mod 120): RSA key
admin
arith invmod 7 120
mentdb
103
Check: 3 x 4 mod 11 = 1
admin
arith irem 12 11
mentdb
1
Not coprime: no inverse
admin
arith invmod 4 8
mentdb
Sorry, an error appears (4 is not invertible modulo 8 (gcd = 4)).
arith isqrt <n>
Description
Get the integer square root: the largest integer r with r^2 <= n
Get the integer square root: the largest integer r with r^2 <= n
Parameters
n: An integer >= 0 - Number - required
n: An integer >= 0 - Number - required
Examples (4)
admin
arith isqrt 99
mentdb
9
Exact integer square root of a large number
admin
arith isqrt 1000000000000000000000
mentdb
31622776601
Perfect square
admin
arith isqrt 144
mentdb
12
isqrt(0) = 0
admin
arith isqrt 0
mentdb
0
arith phi <n>
Description
Get the Euler totient: the number of integers in [1, n] coprime with n
Get the Euler totient: the number of integers in [1, n] coprime with n
Parameters
n: An integer >= 1 - Number - required
n: An integer >= 1 - Number - required
Examples (4)
admin
arith phi 36
mentdb
12
Euler phi of a prime: p - 1
admin
arith phi 97
mentdb
96
phi(1) = 1
admin
arith phi 1
mentdb
1
RSA: phi(61 x 53) = 60 x 52
admin
arith phi 3233
mentdb
3120
arith powmod <a> <b> <m>
Description
Get a^b mod m (exact, any size; b < 0: power of the modular inverse)
Get a^b mod m (exact, any size; b < 0: power of the modular inverse)
Parameters
a: An integer - Number - required
b: The exponent (integer) - Number - required
m: The modulus (> 0) - Number - required
a: An integer - Number - required
b: The exponent (integer) - Number - required
m: The modulus (> 0) - Number - required
Examples (4)
admin
arith powmod 2 1000 1000000007
mentdb
688423210
RSA style exponentiation
admin
arith powmod 65 17 3233
mentdb
2790
Fermat little theorem: a^(p-1) mod p = 1
admin
arith powmod 3 96 97
mentdb
1
RSA decryption of 2790 with d = 2753
admin
arith powmod 2790 2753 3233
mentdb
65
bigdec abs <x>
Description
Get the absolute value
Get the absolute value
Parameters
x: A decimal number - Number - required
x: A decimal number - Number - required
Examples (3)
admin
bigdec abs -12.50
mentdb
12.50
Positive number
admin
bigdec abs 3.14
mentdb
3.14
Many digits
admin
bigdec abs -0.000000000000000000001
mentdb
0.000000000000000000001
bigdec compare <a> <b>
Description
Compare two decimal numbers: -1 (a < b), 0 (equal: 1.0 = 1.00), 1 (a > b)
Compare two decimal numbers: -1 (a < b), 0 (equal: 1.0 = 1.00), 1 (a > b)
Parameters
a: A decimal number - Number - required
b: A decimal number - Number - required
a: A decimal number - Number - required
b: A decimal number - Number - required
Examples (4)
admin
bigdec compare 1.0 1.00
mentdb
0
a < b: -1
admin
bigdec compare 0.1 0.2
mentdb
-1
a > b: 1
admin
bigdec compare 10 9.99999999999999999999
mentdb
1
Exact sum against 0.3 (0.1 + 0.2)
admin
bigdec compare (bigdec sum "[0.1, 0.2]") 0.3
mentdb
0
bigdec div <a> <b> <precision>
Description
Divide with a number of significant digits (rounding HALF_UP)
Divide with a number of significant digits (rounding HALF_UP)
Parameters
a: A decimal number - Number - required
b: A decimal number - Number - required
precision: The number of significant digits - Number - required
a: A decimal number - Number - required
b: A decimal number - Number - required
precision: The number of significant digits - Number - required
Examples (4)
admin
bigdec div 1 7 50
mentdb
0.14285714285714285714285714285714285714285714285714
1/3 with 30 digits
admin
bigdec div 1 3 30
mentdb
0.333333333333333333333333333333
Exact division
admin
bigdec div 10 4 10
mentdb
2.5
Interest per month: 5 % / 12
admin
bigdec div 0.05 12 20
mentdb
0.0041666666666666666667
bigdec div <a> <b> <precision> <mode>
Description
Divide with a number of significant digits and a rounding mode
Divide with a number of significant digits and a rounding mode
Parameters
a: A decimal number - Number - required
b: A decimal number - Number - required
precision: The number of significant digits - Number - required
mode: The rounding mode - String - required
a: A decimal number - Number - required
b: A decimal number - Number - required
precision: The number of significant digits - Number - required
mode: The rounding mode - String - required
Examples (4)
admin
bigdec div 2 3 5 DOWN
mentdb
0.66666
Rounding up
admin
bigdec div 2 3 5 UP
mentdb
0.66667
Rounding half even (banker)
admin
bigdec div 1 8 2 HALF_EVEN
mentdb
0.12
Rounding half up
admin
bigdec div 1 8 2 HALF_UP
mentdb
0.13
bigdec negate <x>
Description
Get the opposite
Get the opposite
Parameters
x: A decimal number - Number - required
x: A decimal number - Number - required
Examples (3)
admin
bigdec negate 12.5
mentdb
-12.5
Negative number
admin
bigdec negate -0.5
mentdb
0.5
Zero
admin
bigdec negate 0
mentdb
0
bigdec pow <x> <n> <precision>
Description
Get x^n (n integer, can be negative) with a number of significant digits
Get x^n (n integer, can be negative) with a number of significant digits
Parameters
x: A decimal number - Number - required
n: An integer - Number - required
precision: The number of significant digits - Number - required
x: A decimal number - Number - required
n: An integer - Number - required
precision: The number of significant digits - Number - required
Examples (5)
admin
bigdec pow 1.1 10 30
mentdb
2.5937424601
admin
bigdec pow 2 100 50
mentdb
1267650600228229401496703205376
Compound interest 1.05^30
admin
bigdec pow 1.05 30 20
mentdb
4.3219423751506620092
Large exponent: 2^200 exact
admin
bigdec pow 2 200 70
mentdb
1606938044258990275541962092341162602522202993782792835301376
Small numbers
admin
bigdec pow 0.5 20 30
mentdb
0.00000095367431640625
bigdec precision <x> <precision>
Description
Round to a number of significant digits (rounding HALF_UP)
Round to a number of significant digits (rounding HALF_UP)
Parameters
x: A decimal number - Number - required
precision: The number of significant digits - Number - required
x: A decimal number - Number - required
precision: The number of significant digits - Number - required
Examples (3)
admin
bigdec precision 123456.789 4
mentdb
123500
Significant digits of a small number
admin
bigdec precision 0.000123456 3
mentdb
0.000123
Integer
admin
bigdec precision 987654321 2
mentdb
990000000
bigdec precision <x> <precision> <mode>
Description
Round to a number of significant digits with a rounding mode
Round to a number of significant digits with a rounding mode
Parameters
x: A decimal number - Number - required
precision: The number of significant digits - Number - required
mode: The rounding mode - String - required
x: A decimal number - Number - required
precision: The number of significant digits - Number - required
mode: The rounding mode - String - required
Examples (3)
admin
bigdec precision -2.567 2 FLOOR
mentdb
-2.6
Rounding up
admin
bigdec precision 2.561 2 CEILING
mentdb
2.6
Truncate
admin
bigdec precision 2.569 2 DOWN
mentdb
2.5
bigdec round <x> <scale>
Description
Round to a number of decimals (rounding HALF_UP). A negative scale rounds to the tens, hundreds...
Round to a number of decimals (rounding HALF_UP). A negative scale rounds to the tens, hundreds...
Parameters
x: A decimal number - Number - required
scale: The number of decimals - Number - required
x: A decimal number - Number - required
scale: The number of decimals - Number - required
Examples (4)
admin
bigdec round 3.14159 2
mentdb
3.14
admin
bigdec round 1234 -2
mentdb
1200
Money: 2 decimals
admin
bigdec round 19.995 2
mentdb
20.00
Integer
admin
bigdec round 2.5 0
mentdb
3
bigdec round <x> <scale> <mode>
Description
Round to a number of decimals with a rounding mode
Round to a number of decimals with a rounding mode
Parameters
x: A decimal number - Number - required
scale: The number of decimals - Number - required
mode: The rounding mode - String - required
x: A decimal number - Number - required
scale: The number of decimals - Number - required
mode: The rounding mode - String - required
Examples (6)
admin
bigdec round 2.5 0 HALF_EVEN
mentdb
2
Round half up
admin
bigdec round 2.345 2 HALF_UP
mentdb
2.35
Truncate to 2 decimals
admin
bigdec round 2.349 2 DOWN
mentdb
2.34
Toward + infinity
admin
bigdec round -2.341 2 CEILING
mentdb
-2.34
Toward - infinity
admin
bigdec round -2.341 2 FLOOR
mentdb
-2.35
Unknown mode: error
admin
bigdec round 2.345 2 FOO
mentdb
Sorry, an error appears (unknown rounding mode 'FOO' (HALF_UP, HALF_EVEN, HALF_DOWN, UP, DOWN, CEILING, FLOOR)).
bigdec sqrt <x> <precision>
Description
Get the square root with a number of significant digits
Get the square root with a number of significant digits
Parameters
x: A decimal number - Number - required
precision: The number of significant digits - Number - required
x: A decimal number - Number - required
precision: The number of significant digits - Number - required
Examples (4)
admin
bigdec sqrt 2 50
mentdb
1.4142135623730950488016887242096980785696718753769
sqrt(3) with 40 digits
admin
bigdec sqrt 3 40
mentdb
1.732050807568877293527446341505872366943
Perfect square
admin
bigdec sqrt 144 10
mentdb
12
sqrt(2) with 100 digits
admin
bigdec sqrt 2 100
mentdb
1.414213562373095048801688724209698078569671875376948073176679737990732478462107038850387534327641573
bigdec strip <x>
Description
Remove the trailing zeros
Remove the trailing zeros
Parameters
x: A decimal number - Number - required
x: A decimal number - Number - required
Examples (3)
admin
bigdec strip 12.500
mentdb
12.5
Integer with a decimal point
admin
bigdec strip 100.000
mentdb
100
No zero to remove
admin
bigdec strip 1.25
mentdb
1.25
bigdec e <precision>
Description
Get e with a number of significant digits (up to 10000, binary splitting)
Get e with a number of significant digits (up to 10000, binary splitting)
Parameters
precision: The number of significant digits - Number - required
precision: The number of significant digits - Number - required
Examples (3)
admin
bigdec e 50
mentdb
2.7182818284590452353602874713526624977572470937000
e with 100 digits
admin
bigdec e 100
mentdb
2.718281828459045235360287471352662497757247093699959574966967627724076630353547594571382178525166427
e with 10 digits
admin
bigdec e 10
mentdb
2.718281828
bigdec mean <json_array> <precision>
Description
Get the exact mean of a JSON array of decimal numbers, with a number of significant digits
Get the exact mean of a JSON array of decimal numbers, with a number of significant digits
Parameters
json_array: A JSON array of decimal numbers - String - required
precision: The number of significant digits - Number - required
json_array: A JSON array of decimal numbers - String - required
precision: The number of significant digits - Number - required
Examples (3)
admin
bigdec mean "[1, 2, 2]" 20
mentdb
1.6666666666666666667
Exact mean of money values
admin
bigdec mean "[19.99, 5.01, 0.10]" 10
mentdb
8.366666667
Mean with 30 digits
admin
bigdec mean "[1, 2, 4]" 30
mentdb
2.33333333333333333333333333333
bigdec pi <precision>
Description
Get pi with a number of significant digits (up to 10000, Chudnovsky formula)
Get pi with a number of significant digits (up to 10000, Chudnovsky formula)
Parameters
precision: The number of significant digits - Number - required
precision: The number of significant digits - Number - required
Examples (4)
admin
bigdec pi 50
mentdb
3.1415926535897932384626433832795028841971693993751
100 digits of pi
admin
bigdec pi 100
mentdb
3.141592653589793238462643383279502884197169399375105820974944592307816406286208998628034825342117068
10 digits
admin
bigdec pi 10
mentdb
3.141592654
1000 digits
admin
bigdec pi 1000
mentdb
3.14159265358979323846264338327950288419716939937510582097494459230781640628620899862803482534211706798214808651328230664709384460955058223172535940812848111745028410270193852110555964462294895493038196442881097566593344612847564823378678316527120190914564856692346034861045432664821339360726024914127372458700660631558817488152092096282925409171536436789259036001133053054882046652138414695194151160943305727036575959195309218611738193261179310511854807446237996274956735188575272489122793818301194912983367336244065664308602139494639522473719070217986094370277053921717629317675238467481846766940513200056812714526356082778577134275778960917363717872146844090122495343014654958537105079227968925892 ...
bigdec sum <json_array>
Description
Get the exact sum of a JSON array of decimal numbers (0.1 + 0.2 = 0.3)
Get the exact sum of a JSON array of decimal numbers (0.1 + 0.2 = 0.3)
Parameters
json_array: A JSON array of decimal numbers - String - required
json_array: A JSON array of decimal numbers - String - required
Examples (4)
admin
bigdec sum "[0.1, 0.2]"
mentdb
0.3
Money: no rounding error
admin
bigdec sum "[19.99, 5.01, 0.10]"
mentdb
25.10
Large and small numbers without loss
admin
bigdec sum "[1e20, 1, -1e20]"
mentdb
1
Negative values
admin
bigdec sum "[10.10, -3.33, -6.77]"
mentdb
0.00
