mpf_const_pi.c

来自「精确小数算法库,可以实现任意长度的精确小数算法,用c语言实现,主要用于密码学中小」· C语言 代码 · 共 33 行

C
33
字号
/* LibTomFloat, multiple-precision floating-point library * * LibTomFloat is a library that provides multiple-precision * floating-point artihmetic as well as trigonometric functionality. * * This library requires the public domain LibTomMath to be installed. *  * This library is free for all purposes without any express * gurantee it works * * Tom St Denis, tomstdenis@iahu.ca, http://float.libtomcrypt.org */#include <tomfloat.h>/* Pi = 4arctan(1) */int  mpf_const_pi(mp_float *a){   int err;   if ((err = mpf_const_d(a, 1)) != MP_OKAY) {      return err;   }   if ((err = mpf_atan(a, a)) != MP_OKAY) {      return err;   }   if ((err = mpf_mul_2(a, a)) != MP_OKAY) {      return err;   }   return mpf_mul_2(a, a);}                /* Pi      */

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?