after multiple objections of libtom users [1], we decided to change licensing
[libtomfloat.git] / mpf_const_pi.c
blob8427c6c290e6f482c97798a65a865911f4a65f19
1 /* LibTomFloat, multiple-precision floating-point library
3 * LibTomFloat is a library that provides multiple-precision
4 * floating-point artihmetic as well as trigonometric functionality.
6 * This library requires the public domain LibTomMath to be installed.
7 *
8 * This library is free for all purposes without any express
9 * gurantee it works
11 * Tom St Denis, tomstdenis@iahu.ca, http://float.libtomcrypt.org
13 #include <tomfloat.h>
16 /* Pi = 4arctan(1) */
17 int mpf_const_pi(mp_float *a)
19 int err;
20 if ((err = mpf_const_d(a, 1)) != MP_OKAY) {
21 return err;
23 if ((err = mpf_atan(a, a)) != MP_OKAY) {
24 return err;
26 if ((err = mpf_mul_2(a, a)) != MP_OKAY) {
27 return err;
29 return mpf_mul_2(a, a);
31 /* Pi */