Questions tagged [arbitrary-precision]

All questions concerning numbers which support extremely high precision: Libraries in programming languages (GMP, MPFR), support of arbitrary precision in computer algebra systems (CAS, Mathematica, Maple, Mathlab) and how to correctly use and calculate numbers with very high precision and accuracy.

Sometimes the available precision of hardware-supported datatypes (most likely single precision (=32bit), double precision (=64bit), extended precision (=80bit)) is not enough to tackle some problems:

  • Problems given in natural sciences and applied and theoretical mathematics which needs utmost precision. These are mostly tackled by computer algebra systems like Mathematica and Maple.
  • Financial applications which must confirm to the exact rounding procedures given by law. They also should guarantee that the available range of numbers is big enough so that nonsensical results by leaving the supported range (overflow) will not occur.
  • Cryptological applications which need to handle very large integers because many algorithms (integer factorization, Diffie-Hellman key exchange) are based on them.

In this case speed and portability is sacrificed to support numbers with a much higher precision available than hardware-supported datatypes. They are called arbitrary-precision numbers.

As the handling of arbitrary-precision numbers and arithmetic is not standardized yet, there may be big differences between implementations. There are different packages supporting one or more arbitrary-precision datatypes: integer, binary and decimal float or rational.

The tag should be applied to all questions which need to use arbitrary-precision numbers: Problems which need high precision, the implementation of arbitrary-precision numbers, the programming of basic operations, known caveats of specific packages etc. Some programming languages have built-in capabilities to handle arbitrary-precision (BigDecimal in Java, Bignum in Ruby).

Free software:

Axiom: Free computer algebra system with arbitrary-precision capabilities.

GMP: GNU Multiple Precision Arithmetic Library

Important books:

Knuth, D. E. The Art of Computer Programming, Vol. 2: Seminumerical Algorithms, 3rd ed. Reading, MA: Addison-Wesley, 1998.

Muller, Jean-Michel et al. Handbook of Floating-Point Arithmetic, Chapter 14, Birkhäuser Boston, 2009.

296 questions
-1
votes
2 answers

Double precision and quadruple precision in MATLAB

I want to convert data(double precision,15 decimal points) to data of another type(quadruple precision,34 decimal points). So, I used vpa function like this: data = sin(2*pi*frequency*time); quad_data = vpa(data,34); But, the type of the result is…
-1
votes
1 answer

Calculate Pi with arbitrary precision digit by digit

So I want to output Pi with arbitrary precision digit by digit. I found some code here https://rosettacode.org/wiki/Pi#C.23 public IEnumerable PiDigits(long b = 10) { BigInteger k = 1, l = 3, n =…
Simon Rusinov
  • 19
  • 1
  • 5
-1
votes
3 answers

Is it possible to create an SVG that is precise to 1,000,000,000% zoom?

Split off from: https://stackoverflow.com/questions/31076846/is-it-possible-to-use-javascript-to-draw-an-svg-that-is-precise-to-1-000-000-000 The SVG spec states that SVGs use double-precision floats for all values. Through testing, it's easy to…
joshfindit
  • 500
  • 5
  • 21
-1
votes
1 answer

gmp for R and other sols

implemented a solution to a problem in arithmetic precision handeling in gmp - but the results are rather strange . as a part of troubleshooting I was wondering whether there is any other package hich woudl allow similar operatiosn as gmp in R. I…
heineman
  • 25
  • 6
-1
votes
4 answers

C++ pow() function produces arbitrarily precise result

If double precision does not guarantee more than 16 significant decimal digits, how is such an output generated by this standard C++ program? Also small value change operations done on "ans" such as ++ans don't alter the screen output. Is the answer…
-2
votes
1 answer

Why does Python floor division return a float when the divisor and/or dividend is a float?

If I understand correctly, the return value for floor division is always a whole number, even if the dividend and/or divisor are not whole numbers, so why does it not always return an integer. It's detrimental in my case because converting from a…
-2
votes
1 answer

Divide arbitrary binary integers by 3 in python

All the binary integers am given are always divisible by 3 so no floating-point values involved. The return value must also be a binary string Tried this but a and h are different yet they should be >>>…
Mpiima
  • 3
  • 4
-2
votes
3 answers

Why does the program ends even before running?

I want to use this question to improve a bit in my general understanding of how computer works, since I'll probably never have the chance to study in a profound and deep manner. Sorry in advance if the question is silly and not useful in general,…
RenatoRenatoRenato
  • 277
  • 1
  • 2
  • 12
-3
votes
1 answer

How to implement bignum addition/multiplication from scratch in C++

I have started writing a bignum library, with a vector of shorts to represent the value, a print function, and negative number support. However, I cannot find a good way to implement long addition, like this: 123 +123 ---- 246 The latest code I…
built1n
  • 1,428
  • 14
  • 24
-4
votes
3 answers

Division for two arbitrary precision binary integers

I've got two integer numbers in binary form, num1 and num2 stored as strings containing "0"s and "1"s. What would be the best algorithm to divide num1 by num2 in order to obtain a floating-point double result?
Desmond Hume
  • 6,732
  • 13
  • 57
  • 104
-4
votes
1 answer

Improving speed of my mpmath code

Hello I wrote some code in Python, using the mpmath, arbitrary precision math module: from __future__ import division from numpy import arctan, sin, absolute, log10 from mpmath import * import time imax = 1000001 x = mpf(0) y = mpf(0) z = mpf(0) t =…
1 2 3
19
20