A high-precision square root calculator implemented in Haskell using the GMP (GNU Multiple Precision Arithmetic Library) for accurate big-integer computations.
This program computes the square root of a given number up to a specified number of digits of precision.
Ensure that GCC, GHC, and GMP are installed. To build and execute:
cd sqrt
gcc -c cbits/wrappers.c -o cbits/wrappers.o
ghc -O2 sqrt.hs cbits/wrappers.o -o sqrt
./sqrt <n> <digits>
Example:
cd sqrt
gcc -c cbits/wrappers.c -o cbits/wrappers.o
ghc -O2 sqrt.hs cbits/wrappers.o -o sqrt
./sqrt 2 50
Output:
√2 to 50 digits is: 1.41421356237309504880168872420969807856967187537694
mpz_sqrt
for efficient integer square root calculation.Abhrankan Chakrabarti