after multiple objections of libtom users [1], we decided to change licensing
[libtomfloat.git] / mpf_const_d.c
blob240073f258f07fa4e7e693076dede2222c659a33
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_const_d(mp_float *a, long d)
17 long x, s;
18 int err;
20 if (d < 0) {
21 x = -d;
22 s = MP_NEG;
23 } else {
24 x = d;
25 s = MP_ZPOS;
28 if ((err = mp_set_int(&(a->mantissa), x)) != MP_OKAY) {
29 return err;
32 a->mantissa.sign = s;
33 a->exp = 0;
34 return mpf_normalize(a);