added libtomfloat-0.01
[libtomfloat.git] / mpf_cmp_d.c
blob401ad252b177138890bfc009e7a21438c0c48f87
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>
15 int mpf_cmp_d(mp_float *a, long b, int *res)
17 int err;
18 mp_float tmp;
20 if ((err = mpf_init(&tmp, a->radix)) != MP_OKAY) {
21 return err;
24 if ((err = mpf_const_d(&tmp, b)) != MP_OKAY) { goto __ERR; }
25 *res = mpf_cmp(a, &tmp);
27 __ERR:
28 mpf_clear(&tmp);
29 return err;