wcalc  2.5
About: Wcalc is a natural-expression command-line calculator.
  Fossies Dox: wcalc-2.5.tar.gz  ("inofficial" and yet experimental doxygen-generated source code documentation)  

number.c
Go to the documentation of this file.
1 #ifdef HAVE_CONFIG_H
2 # include "config.h"
3 #endif
4 
5 /* System Headers */
6 #include <sys/time.h> /* for gettimeofday() */
7 #include <stdio.h> /* for perror() */
8 #include <string.h> /* for strlen() */
9 #include <stdlib.h> /* for atexit() */
10 
11 /* Internal Headers */
12 #include "number.h"
13 #include "calculator.h"
14 
15 #ifdef HAVE_LIBMPFR
16 gmp_randstate_t randstate;
17 #endif
18 
19 static void numbers_cleanup(void)
20 { /*{{{*/
21 #ifdef HAVE_LIBMPFR
22  mpfr_free_cache();
23 #endif
24 } /*}}}*/
25 
26 void init_numbers(void)
27 { /*{{{*/
28 #ifdef HAVE_LIBMPFR
29  struct timeval tp;
30  /* seed the random number generator */
31  if (gettimeofday(&tp, NULL) != 0) {
32  perror("gettimeofday");
33  exit(EXIT_FAILURE);
34  }
35  gmp_randinit_default(randstate);
36  gmp_randseed_ui(randstate, (unsigned long)(tp.tv_usec));
37  mpfr_set_default_prec(1024);
38 #else
39  srandom(time(NULL));
40 #endif /* ifdef HAVE_LIBMPFR */
41  atexit(numbers_cleanup);
42 } /*}}}*/
43 
44 int is_int(const Number potential_int)
45 { /*{{{*/
46  Number temp;
47  int ret;
48 
49  num_init(temp);
50 #ifdef HAVE_LIBMPFR
51  ret = num_trunc(temp, potential_int);
52  num_free(temp);
53  switch(ret) {
54  case 2: case -2: return 0;
55  default: return 1;
56  }
57 #else
58  num_trunc(temp, potential_int);
59  ret = num_is_equal(temp, potential_int);
60  num_free(temp);
61  return ret;
62 #endif
63 } /*}}}*/
64 
65 #ifndef HAVE_LIBMPFR
66 # include <errno.h>
67 # include <math.h> /* for HUGE_VAL, according to C89 */
68 
70 {
71  n->nan = 1;
72 }
73 
75  const Number n2)
76 {
77  num_init(n1);
78  memcpy(n1, n2, sizeof(struct numberstruct));
79 }
80 
82  const double d)
83 {
84  num_init(n);
85  n->value = d;
86  n->nan = 0;
87 }
88 
90  const unsigned int ui)
91 {
92  num_init(n);
93  n->value = (double)ui;
94  n->nan = 0;
95 }
96 
98  const char *str,
99  const int base)
100 {
101  num_init(n);
102  return num_set_str(n, str, base);
103 }
104 
105 void num_set(Number n1,
106  const Number n2)
107 {
108  memcpy(n1, n2, sizeof(struct numberstruct));
109 }
110 
112  const double d)
113 {
114  n->value = d;
115  n->nan = 0;
116 }
117 
119  const unsigned int ui)
120 {
121  n->value = (double)ui;
122  n->nan = 0;
123 }
124 
126  const char *str,
127  const int base)
128 {
129  char *endptr;
130 
131  Dprintf("base = %i, %c%c\n", base, str[0], str[1]);
132  errno = 0;
133  n->value = strtod(str, &endptr);
134  if (endptr == str) {
135  return -1;
136  }
137  if ((errno == ERANGE) && ((n->value == HUGE_VAL) || (n->value == 0.0))) {
138  n->nan = 1;
139  return -1;
140  }
141  n->nan = 0;
142  return 0;
143 }
144 
146 {
147  n->value = 0.0;
148  n->nan = 1;
149 }
150 
151 void num_mul(Number ret,
152  const Number n1,
153  const Number n2)
154 {
155  if ((n1->nan == 0) && (n2->nan == 0)) {
156  num_set_d(ret, n1->value * n2->value);
157  } else {
158  num_set_nan(ret);
159  }
160 }
161 
163  const Number n,
164  const int si)
165 {
166  if (n->nan == 0) {
167  num_set_d(ret, n->value * si);
168  } else {
169  num_set_nan(ret);
170  }
171 }
172 
174  const Number n,
175  const unsigned int ui)
176 {
177  if (n->nan == 0) {
178  num_set_d(ret, n->value * ui);
179  } else {
180  num_set_nan(ret);
181  }
182 }
183 
184 void num_sqr(Number ret,
185  const Number n)
186 {
187  num_mul(ret, n, n);
188 }
189 
190 void num_sqrt(Number ret,
191  const Number n)
192 {
193  if ((n->nan == 0) && (n->value >= 0.0)) {
194  num_set_d(ret, sqrt(n->value));
195  } else {
196  num_set_nan(ret);
197  }
198 }
199 
200 void num_cbrt(Number ret,
201  const Number n)
202 {
203  if (n->nan == 0) {
204  num_set_d(ret, cbrt(n->value));
205  } else {
206  num_set_nan(ret);
207  }
208 }
209 
210 void num_pow(Number ret,
211  const Number n,
212  const Number exp)
213 {
214  if ((n->nan == 0) && (exp->nan == 0)) {
215  errno = 0;
216  num_set_d(ret, pow(n->value, exp->value));
217  if (errno == EDOM) {
218  num_set_nan(ret);
219  }
220  } else {
221  num_set_nan(ret);
222  }
223 }
224 
226  const Number n,
227  const int exp)
228 {
229  if (n->nan == 0) {
230  errno = 0;
231  num_set_d(ret, pow(n->value, exp));
232  if (errno == EDOM) {
233  num_set_nan(ret);
234  }
235  } else {
236  num_set_nan(ret);
237  }
238 }
239 
240 void num_exp(Number ret,
241  const Number n)
242 {
243  if (n->nan == 0) {
244  num_set_d(ret, exp(n->value));
245  } else {
246  num_set_nan(ret);
247  }
248 }
249 
251  unsigned int n)
252 {
253  ret->value = (double)n;
254  n--;
255  while (n > 1 && ret->value < DBL_MAX) {
256  ret->value *= n;
257  n--;
258  }
259  if (ret->value < DBL_MAX) {
260  ret->nan = 0;
261  } else {
262  num_set_nan(ret);
263  }
264 }
265 
266 void num_log10(Number ret,
267  const Number n)
268 {
269  if ((n->nan == 0) && (n->value > 0.0)) {
270  num_set_d(ret, log10(n->value));
271  } else {
272  num_set_nan(ret);
273  }
274 }
275 
276 void num_log2(Number ret,
277  const Number n)
278 {
279  if ((n->nan == 0) && (n->value > 0.0)) {
280  num_set_d(ret, log10(n->value) / log10(2.0));
281  } else {
282  num_set_nan(ret);
283  }
284 }
285 
286 void num_log(Number ret,
287  const Number n)
288 {
289  if ((n->nan == 0) && (n->value > 0.0)) {
290  num_set_d(ret, log(n->value));
291  } else {
292  num_set_nan(ret);
293  }
294 }
295 
296 void num_sin(Number ret,
297  const Number n)
298 {
299  if (n->nan == 0) {
300  num_set_d(ret, sin(n->value));
301  } else {
302  num_set_nan(ret);
303  }
304 }
305 
306 void num_cos(Number ret,
307  const Number n)
308 {
309  if (n->nan == 0) {
310  num_set_d(ret, cos(n->value));
311  } else {
312  num_set_nan(ret);
313  }
314 }
315 
316 void num_tan(Number ret,
317  const Number n)
318 {
319  if (n->nan == 0) {
320  num_set_d(ret, tan(n->value));
321  } else {
322  num_set_nan(ret);
323  }
324 }
325 
326 void num_asin(Number ret,
327  const Number n)
328 {
329  if (n->nan == 0) {
330  num_set_d(ret, asin(n->value));
331  } else {
332  num_set_nan(ret);
333  }
334 }
335 
336 void num_acos(Number ret,
337  const Number n)
338 {
339  if (n->nan == 0) {
340  num_set_d(ret, acos(n->value));
341  } else {
342  num_set_nan(ret);
343  }
344 }
345 
346 void num_atan(Number ret,
347  const Number n)
348 {
349  if (n->nan == 0) {
350  num_set_d(ret, atan(n->value));
351  } else {
352  num_set_nan(ret);
353  }
354 }
355 
356 void num_sinh(Number ret,
357  const Number n)
358 {
359  if (n->nan == 0) {
360  num_set_d(ret, sinh(n->value));
361  } else {
362  num_set_nan(ret);
363  }
364 }
365 
366 void num_cosh(Number ret,
367  const Number n)
368 {
369  if (n->nan == 0) {
370  num_set_d(ret, cosh(n->value));
371  } else {
372  num_set_nan(ret);
373  }
374 }
375 
376 void num_tanh(Number ret,
377  const Number n)
378 {
379  if (n->nan == 0) {
380  num_set_d(ret, tanh(n->value));
381  } else {
382  num_set_nan(ret);
383  }
384 }
385 
386 void num_asinh(Number ret,
387  const Number n)
388 {
389  if (n->nan == 0) {
390  num_set_d(ret, asinh(n->value));
391  } else {
392  num_set_nan(ret);
393  }
394 }
395 
396 void num_acosh(Number ret,
397  const Number n)
398 {
399  if (n->nan == 0) {
400  num_set_d(ret, acosh(n->value));
401  } else {
402  num_set_nan(ret);
403  }
404 }
405 
406 void num_atanh(Number ret,
407  const Number n)
408 {
409  if (n->nan == 0) {
410  num_set_d(ret, atanh(n->value));
411  } else {
412  num_set_nan(ret);
413  }
414 }
415 
416 void num_acoth(Number ret,
417  const Number n)
418 {
419  if ((n->nan == 0) && !num_is_zero(n)) {
420  num_set_d(ret, atanh(1.0 / n->value));
421  } else {
422  num_set_nan(ret);
423  }
424 }
425 
426 void num_asech(Number ret,
427  const Number n)
428 {
429  if ((n->nan == 0) && !num_is_zero(n)) {
430  num_set_d(ret, acosh(1.0 / n->value));
431  } else {
432  num_set_nan(ret);
433  }
434 }
435 
436 void num_acsch(Number ret,
437  const Number n)
438 {
439  if ((n->nan == 0) && !num_is_zero(n)) {
440  num_set_d(ret, asinh(1.0 / n->value));
441  } else {
442  num_set_nan(ret);
443  }
444 }
445 
446 double num_get_d(const Number n)
447 {
448  return n->value;
449 }
450 
451 unsigned int num_get_ui(const Number n)
452 {
453  return (unsigned int)n->value;
454 }
455 
456 char *num_get_str(char *str,
457  num_exp_t *expptr,
458  const int b,
459  const size_t n,
460  const Number op)
461 {
462  char *dec;
463 
464  if (!str) { str = malloc(1024); }
465  sprintf(str, "%.1000g", op->value);
466  //printf("the str: %s\n", str);
467  dec = strchr(str, conf.dec_delimiter);
468  if (dec == NULL) {
469  *expptr = strlen(str);
470  }
471  if (str[0] == -1) {
472  *expptr -= 1;
473  }
475  //printf("the str (2): %s\n", str);
476  return str;
477 }
478 
480 {
481  return DBL_MANT_DIG;
482 }
483 
484 void num_add(Number ret,
485  const Number n1,
486  const Number n2)
487 {
488  if ((n1->nan == 0) && (n2->nan == 0)) {
489  num_set_d(ret, n1->value + n2->value);
490  } else {
491  num_set_nan(ret);
492  }
493 }
494 
495 void num_sub(Number ret,
496  const Number n1,
497  const Number n2)
498 {
499  if ((n1->nan == 0) && (n2->nan == 0)) {
500  num_set_d(ret, n1->value - n2->value);
501  } else {
502  num_set_nan(ret);
503  }
504 }
505 
507  const Number n,
508  const unsigned int ui)
509 {
510  if (n->nan == 0) {
511  num_set_d(ret, n->value + ui);
512  } else {
513  num_set_nan(ret);
514  }
515 }
516 
518  const Number n,
519  const unsigned int ui)
520 {
521  if (n->nan == 0) {
522  num_set_d(ret, n->value - ui);
523  } else {
524  num_set_nan(ret);
525  }
526 }
527 
528 void num_div(Number ret,
529  const Number n1,
530  const Number n2)
531 {
532  if ((n1->nan == 0) && (n2->nan == 0) && (n2->value != 0.0)) {
533  num_set_d(ret, n1->value / n2->value);
534  } else {
535  num_set_nan(ret);
536  }
537 }
538 
540  const Number n,
541  const unsigned int ui)
542 {
543  if ((n->nan == 0) && (ui != 0)) {
544  num_set_d(ret, n->value / ui);
545  } else {
546  num_set_nan(ret);
547  }
548 }
549 
550 void num_rint(Number ret,
551  const Number n)
552 {
553  if (n->nan == 0) {
554  num_set_d(ret, rint(n->value));
555  } else {
556  num_set_nan(ret);
557  }
558 }
559 
560 void num_rintz(Number ret,
561  const Number n)
562 {
563  if (n->nan == 0) {
564  if (n->value < 0.0) {
565  num_set_d(ret, ceil(n->value));
566  } else {
567  num_set_d(ret, floor(n->value));
568  }
569  } else {
570  num_set_nan(ret);
571  }
572 }
573 
574 void num_floor(Number ret,
575  const Number n)
576 {
577  if (n->nan == 0) {
578  num_set_d(ret, floor(n->value));
579  } else {
580  num_set_nan(ret);
581  }
582 }
583 
584 void num_ceil(Number ret,
585  const Number n)
586 {
587  if (n->nan == 0) {
588  num_set_d(ret, ceil(n->value));
589  } else {
590  num_set_nan(ret);
591  }
592 }
593 
595 {
596  num_set_d(n, random() / (double)RAND_MAX);
597  return 0;
598 }
599 
600 void num_sinc(Number ret,
601  const Number n)
602 {
603  if (n->nan == 0) {
604  if (num_is_zero(n)) {
605  num_set_d(ret, 1);
606  } else {
607  num_sin(ret, n);
608  num_div(ret, ret, n);
609  }
610  } else {
611  num_set_nan(ret);
612  }
613 }
614 
616 {
617  num_set_d(n, atan(1) * 4.0); // as accurate as the underlying math library can do
618 }
619 
621 {
622  num_set_d(n, 0.57721566490153286060651209008240243104215933593992359880576723488486772677766467093694706329174674951463144724980708248096050401448654283622417399764492353625350033374293733773767394279259525824709491600873520394816567);
623 }
624 
626 {
627  num_set_d(n, 0.91596559417721901505460351493238411077414937428167213426649811962176301977625476947935651292611510624857442261919619957903589880332585905943159473748115840);
628 }
629 
630 void num_out_str(FILE *fd,
631  const int base,
632  const Number n)
633 {
634  if (n->nan == 1) {
635  fprintf(fd, "@NaN@");
636  return;
637  }
638  switch (base) {
639  case 10:
640  fprintf(fd, "%g", n->value); break;
641  case 16:
642  fprintf(fd, "%#x", (unsigned int)(n->value)); break;
643  case 8:
644  fprintf(fd, "%#o", (unsigned int)(n->value)); break;
645  default:
646  fprintf(fd, "-->oops!<--");
647  }
648 }
649 
650 int num_is_nan(const Number n)
651 {
652  return n->nan;
653 }
654 
655 int num_is_inf(const Number n)
656 {
657  return (n->nan == 0 && isinf(n->value));
658 }
659 
660 int num_is_zero(const Number n)
661 {
662  return (n->nan == 0 && n->value == 0.0);
663 }
664 
665 int num_is_equal(const Number n1,
666  const Number n2)
667 {
668  return (n1->nan == 0 && n2->nan == 0 && n1->value == n2->value);
669 }
670 
671 int num_is_greater(const Number n1,
672  const Number n2)
673 {
674  return (n1->nan == 0 && n2->nan == 0 && n1->value > n2->value);
675 }
676 
678  const Number n2)
679 {
680  return (n1->nan == 0 && n2->nan == 0 && n1->value >= n2->value);
681 }
682 
683 int num_is_less(const Number n1,
684  const Number n2)
685 {
686  return (n1->nan == 0 && n2->nan == 0 && n1->value < n2->value);
687 }
688 
690  const Number n2)
691 {
692  return (n1->nan == 0 && n2->nan == 0 && n1->value <= n2->value);
693 }
694 
695 int num_sign(const Number n)
696 {
697  if (n->value > 0.0) {
698  return 1;
699  } else if (n->value < 0.0) {
700  return -1;
701  } else {
702  return 0;
703  }
704 }
705 
706 void num_neg(Number ret,
707  const Number n)
708 {
709  if (n->nan == 0) {
710  num_set_d(ret, n->value * -1);
711  } else {
712  num_set_nan(ret);
713  }
714 }
715 
716 void num_abs(Number ret,
717  const Number n)
718 {
719  if (n->nan == 0) {
720  num_set_d(ret, fabs(n->value));
721  } else {
722  num_set_nan(ret);
723  }
724 }
725 
726 int num_cmp_si(const Number n,
727  const int si)
728 {
729  if (n->value > si) {
730  return 1;
731  } else if (n->value < si) {
732  return -1;
733  } else {
734  return 0;
735  }
736 }
737 
739 {}
740 
741 void num_cot(Number ret,
742  const Number n)
743 {
744  num_tan(ret, n);
745  if ((ret->nan == 0) && !num_is_zero(ret)) {
746  num_set_d(ret, 1.0 / ret->value);
747  }
748 }
749 
750 void num_sec(Number ret,
751  const Number n)
752 {
753  num_cos(ret, n);
754  if ((ret->nan == 0) && !num_is_zero(ret)) {
755  num_set_d(ret, 1.0 / ret->value);
756  }
757 }
758 
759 void num_csc(Number ret,
760  const Number n)
761 {
762  num_sin(ret, n);
763  if ((ret->nan == 0) && !num_is_zero(ret)) {
764  num_set_d(ret, 1.0 / ret->value);
765  }
766 }
767 
768 void num_coth(Number ret,
769  const Number n)
770 {
771  num_tanh(ret, n);
772  if ((ret->nan == 0) && !num_is_zero(ret)) {
773  num_set_d(ret, 1.0 / ret->value);
774  }
775 }
776 
777 void num_sech(Number ret,
778  const Number n)
779 {
780  num_cosh(ret, n);
781  if ((ret->nan == 0) && !num_is_zero(ret)) {
782  num_set_d(ret, 1.0 / ret->value);
783  }
784 }
785 
786 void num_csch(Number ret,
787  const Number n)
788 {
789  num_sinh(ret, n);
790  if ((ret->nan == 0) && !num_is_zero(ret)) {
791  num_set_d(ret, 1.0 / ret->value);
792  }
793 }
794 
795 void num_comp(Number ret,
796  const Number n)
797 {
798  if (n->nan == 0) {
799  num_set_d(ret, (((int)(n->value)) * -1) - 1);
800  } else {
801  num_set_nan(ret);
802  }
803 }
804 
805 void num_bnot(Number ret,
806  const Number n)
807 {
808  if (n->nan == 0) {
809  num_set_ui(ret, ~num_get_ui(n));
810  } else {
811  num_set_nan(ret);
812  }
813 }
814 
815 void num_band(Number ret,
816  const Number n1,
817  const Number n2)
818 {
819  if ((n1->nan == 0) && (n2->nan == 0)) {
820  num_set_ui(ret, num_get_ui(n1) & num_get_ui(n2));
821  } else {
822  num_set_nan(ret);
823  }
824 }
825 
826 void num_bxor(Number ret,
827  const Number n1,
828  const Number n2)
829 {
830  if ((n1->nan == 0) && (n2->nan == 0)) {
831  num_set_ui(ret, num_get_ui(n1) ^ num_get_ui(n2));
832  } else {
833  num_set_nan(ret);
834  }
835 }
836 
837 void num_bor(Number ret,
838  const Number n1,
839  const Number n2)
840 {
841  if ((n1->nan == 0) && (n2->nan == 0)) {
842  num_set_ui(ret, num_get_ui(n1) | num_get_ui(n2));
843  } else {
844  num_set_nan(ret);
845  }
846 }
847 
848 void num_trunc(Number ret,
849  const Number n)
850 {
851  if (n->nan == 0) {
852  num_set_d(ret, trunc(n->value));
853  } else {
854  num_set_nan(ret);
855  }
856 }
857 
859 {
860  fprintf(stderr, "This function is unimplemented when not using libmpfr.\n");
861 }
862 
863 #endif /* ifndef HAVE_LIBMPFR */
864 /* vim:set expandtab: */
num_cosh
void num_cosh(Number ret, const Number n)
Definition: number.c:366
num_sqr
void num_sqr(Number ret, const Number n)
Definition: number.c:184
num_init_set_d
void num_init_set_d(Number n, const double d)
Definition: number.c:81
numbers_cleanup
static void numbers_cleanup(void)
Definition: number.c:19
num_cmp_si
int num_cmp_si(const Number n, const int si)
Definition: number.c:726
num_asech
void num_asech(Number ret, const Number n)
Definition: number.c:426
num_exp_t
mp_exp_t num_exp_t
Definition: number.h:35
strchr
#define strchr
Definition: variables.h:11
num_init_set
void num_init_set(Number n1, const Number n2)
Definition: number.c:74
num_get_str
char * num_get_str(char *str, num_exp_t *expptr, const int b, const size_t n, const Number op)
Definition: number.c:456
conf
struct _conf conf
Definition: calculator.c:111
num_log10
void num_log10(Number ret, const Number n)
Definition: number.c:266
num_factorial
void num_factorial(Number ret, unsigned int n)
Definition: number.c:250
num_unimplemented
void num_unimplemented()
Definition: number.c:858
calculator.h
num_sqrt
void num_sqrt(Number ret, const Number n)
Definition: number.c:190
strstrip
void strstrip(const char, char *)
Definition: string_manip.c:29
num_sec
void num_sec(Number ret, const Number n)
Definition: number.c:750
num_cbrt
void num_cbrt(Number ret, const Number n)
Definition: number.c:200
num_is_inf
int num_is_inf(const Number n)
Definition: number.c:655
num_random
int num_random(Number n)
Definition: number.c:594
num_pow
void num_pow(Number ret, const Number n, const Number exp)
Definition: number.c:210
num_asinh
void num_asinh(Number ret, const Number n)
Definition: number.c:386
num_get_ui
unsigned int num_get_ui(const Number n)
Definition: number.c:451
num_const_catalan
void num_const_catalan(Number n)
Definition: number.c:625
num_acos
void num_acos(Number ret, const Number n)
Definition: number.c:336
num_add
void num_add(Number ret, const Number n1, const Number n2)
Definition: number.c:484
num_set_d
void num_set_d(Number n, const double d)
Definition: number.c:111
num_init_set_ui
void num_init_set_ui(Number n, const unsigned int ui)
Definition: number.c:89
num_mul_si
void num_mul_si(Number ret, const Number n, const int si)
Definition: number.c:162
num_div
void num_div(Number ret, const Number n1, const Number n2)
Definition: number.c:528
num_is_greater
int num_is_greater(const Number n1, const Number n2)
Definition: number.c:671
num_asin
void num_asin(Number ret, const Number n)
Definition: number.c:326
num_csch
void num_csch(Number ret, const Number n)
Definition: number.c:786
num_const_pi
void num_const_pi(Number n)
Definition: number.c:615
num_pow_si
void num_pow_si(Number ret, const Number n, const int exp)
Definition: number.c:225
num_trunc
void num_trunc(Number ret, const Number n)
Definition: number.c:848
num_is_lessequal
int num_is_lessequal(const Number n1, const Number n2)
Definition: number.c:689
num_floor
void num_floor(Number ret, const Number n)
Definition: number.c:574
num_const_euler
void num_const_euler(Number n)
Definition: number.c:620
num_sub
void num_sub(Number ret, const Number n1, const Number n2)
Definition: number.c:495
num_sech
void num_sech(Number ret, const Number n)
Definition: number.c:777
num_acoth
void num_acoth(Number ret, const Number n)
Definition: number.c:416
num_bxor
void num_bxor(Number ret, const Number n1, const Number n2)
Definition: number.c:826
num_band
void num_band(Number ret, const Number n1, const Number n2)
Definition: number.c:815
num_mul
void num_mul(Number ret, const Number n1, const Number n2)
Definition: number.c:151
num_exp
void num_exp(Number ret, const Number n)
Definition: number.c:240
Dprintf
#define Dprintf(...)
Definition: calculator.h:23
num_prec_t
mp_prec_t num_prec_t
Definition: number.h:131
num_init
void num_init(Number n)
Definition: number.c:69
num_sub_ui
void num_sub_ui(Number ret, const Number n, const unsigned int ui)
Definition: number.c:517
num_is_zero
int num_is_zero(const Number n)
Definition: number.c:660
Number
#define Number
Definition: number.h:23
_conf::dec_delimiter
char dec_delimiter
Definition: calculator.h:126
num_set
void num_set(Number n1, const Number n2)
Definition: number.c:105
num_bor
void num_bor(Number ret, const Number n1, const Number n2)
Definition: number.c:837
isinf
#define isinf(x)
Definition: calculator.c:41
malloc
void * malloc(size_t)
num_div_ui
void num_div_ui(Number ret, const Number n, const unsigned int ui)
Definition: number.c:539
num_neg
void num_neg(Number ret, const Number n)
Definition: number.c:706
num_free
void num_free(Number n)
Definition: number.c:738
num_bnot
void num_bnot(Number ret, const Number n)
Definition: number.c:805
num_tan
void num_tan(Number ret, const Number n)
Definition: number.c:316
num_coth
void num_coth(Number ret, const Number n)
Definition: number.c:768
num_add_ui
void num_add_ui(Number ret, const Number n, const unsigned int ui)
Definition: number.c:506
num_set_ui
void num_set_ui(Number n, const unsigned int ui)
Definition: number.c:118
num_init_set_str
int num_init_set_str(Number n, const char *str, const int base)
Definition: number.c:97
num_acosh
void num_acosh(Number ret, const Number n)
Definition: number.c:396
num_is_greaterequal
int num_is_greaterequal(const Number n1, const Number n2)
Definition: number.c:677
num_log2
void num_log2(Number ret, const Number n)
Definition: number.c:276
init_numbers
void init_numbers(void)
Definition: number.c:26
is_int
int is_int(const Number potential_int)
Definition: number.c:44
num_set_nan
void num_set_nan(Number n)
Definition: number.c:145
num_cot
void num_cot(Number ret, const Number n)
Definition: number.c:741
num_sin
void num_sin(Number ret, const Number n)
Definition: number.c:296
num_sinh
void num_sinh(Number ret, const Number n)
Definition: number.c:356
num_atanh
void num_atanh(Number ret, const Number n)
Definition: number.c:406
num_sign
int num_sign(const Number n)
Definition: number.c:695
num_comp
void num_comp(Number ret, const Number n)
Definition: number.c:795
num_out_str
void num_out_str(FILE *fd, const int base, const Number n)
Definition: number.c:630
num_get_default_prec
num_prec_t num_get_default_prec()
Definition: number.c:479
num_acsch
void num_acsch(Number ret, const Number n)
Definition: number.c:436
num_cos
void num_cos(Number ret, const Number n)
Definition: number.c:306
num_tanh
void num_tanh(Number ret, const Number n)
Definition: number.c:376
num_csc
void num_csc(Number ret, const Number n)
Definition: number.c:759
num_is_nan
int num_is_nan(const Number n)
Definition: number.c:650
num_abs
void num_abs(Number ret, const Number n)
Definition: number.c:716
num_rintz
void num_rintz(Number ret, const Number n)
Definition: number.c:560
num_sinc
void num_sinc(Number ret, const Number n)
Definition: number.c:600
num_ceil
void num_ceil(Number ret, const Number n)
Definition: number.c:584
num_set_str
int num_set_str(Number n, const char *str, const int base)
Definition: number.c:125
number.h
randstate
gmp_randstate_t randstate
num_atan
void num_atan(Number ret, const Number n)
Definition: number.c:346
num_log
void num_log(Number ret, const Number n)
Definition: number.c:286
num_is_less
int num_is_less(const Number n1, const Number n2)
Definition: number.c:683
num_mul_ui
void num_mul_ui(Number ret, const Number n, const unsigned int ui)
Definition: number.c:173
num_rint
void num_rint(Number ret, const Number n)
Definition: number.c:550
num_get_d
double num_get_d(const Number n)
Definition: number.c:446
num_is_equal
int num_is_equal(const Number n1, const Number n2)
Definition: number.c:665