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 File Reference
#include <sys/time.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include "number.h"
#include "calculator.h"
#include <errno.h>
#include <math.h>
Include dependency graph for number.c:

Go to the source code of this file.

Functions

static void numbers_cleanup (void)
 
void init_numbers (void)
 
int is_int (const Number potential_int)
 
void num_init (Number n)
 
void num_init_set (Number n1, const Number n2)
 
void num_init_set_d (Number n, const double d)
 
void num_init_set_ui (Number n, const unsigned int ui)
 
int num_init_set_str (Number n, const char *str, const int base)
 
void num_set (Number n1, const Number n2)
 
void num_set_d (Number n, const double d)
 
void num_set_ui (Number n, const unsigned int ui)
 
int num_set_str (Number n, const char *str, const int base)
 
void num_set_nan (Number n)
 
void num_mul (Number ret, const Number n1, const Number n2)
 
void num_mul_si (Number ret, const Number n, const int si)
 
void num_mul_ui (Number ret, const Number n, const unsigned int ui)
 
void num_sqr (Number ret, const Number n)
 
void num_sqrt (Number ret, const Number n)
 
void num_cbrt (Number ret, const Number n)
 
void num_pow (Number ret, const Number n, const Number exp)
 
void num_pow_si (Number ret, const Number n, const int exp)
 
void num_exp (Number ret, const Number n)
 
void num_factorial (Number ret, unsigned int n)
 
void num_log10 (Number ret, const Number n)
 
void num_log2 (Number ret, const Number n)
 
void num_log (Number ret, const Number n)
 
void num_sin (Number ret, const Number n)
 
void num_cos (Number ret, const Number n)
 
void num_tan (Number ret, const Number n)
 
void num_asin (Number ret, const Number n)
 
void num_acos (Number ret, const Number n)
 
void num_atan (Number ret, const Number n)
 
void num_sinh (Number ret, const Number n)
 
void num_cosh (Number ret, const Number n)
 
void num_tanh (Number ret, const Number n)
 
void num_asinh (Number ret, const Number n)
 
void num_acosh (Number ret, const Number n)
 
void num_atanh (Number ret, const Number n)
 
void num_acoth (Number ret, const Number n)
 
void num_asech (Number ret, const Number n)
 
void num_acsch (Number ret, const Number n)
 
double num_get_d (const Number n)
 
unsigned int num_get_ui (const Number n)
 
char * num_get_str (char *str, num_exp_t *expptr, const int b, const size_t n, const Number op)
 
num_prec_t num_get_default_prec ()
 
void num_add (Number ret, const Number n1, const Number n2)
 
void num_sub (Number ret, const Number n1, const Number n2)
 
void num_add_ui (Number ret, const Number n, const unsigned int ui)
 
void num_sub_ui (Number ret, const Number n, const unsigned int ui)
 
void num_div (Number ret, const Number n1, const Number n2)
 
void num_div_ui (Number ret, const Number n, const unsigned int ui)
 
void num_rint (Number ret, const Number n)
 
void num_rintz (Number ret, const Number n)
 
void num_floor (Number ret, const Number n)
 
void num_ceil (Number ret, const Number n)
 
int num_random (Number n)
 
void num_sinc (Number ret, const Number n)
 
void num_const_pi (Number n)
 
void num_const_euler (Number n)
 
void num_const_catalan (Number n)
 
void num_out_str (FILE *fd, const int base, const Number n)
 
int num_is_nan (const Number n)
 
int num_is_inf (const Number n)
 
int num_is_zero (const Number n)
 
int num_is_equal (const Number n1, const Number n2)
 
int num_is_greater (const Number n1, const Number n2)
 
int num_is_greaterequal (const Number n1, const Number n2)
 
int num_is_less (const Number n1, const Number n2)
 
int num_is_lessequal (const Number n1, const Number n2)
 
int num_sign (const Number n)
 
void num_neg (Number ret, const Number n)
 
void num_abs (Number ret, const Number n)
 
int num_cmp_si (const Number n, const int si)
 
void num_free (Number n)
 
void num_cot (Number ret, const Number n)
 
void num_sec (Number ret, const Number n)
 
void num_csc (Number ret, const Number n)
 
void num_coth (Number ret, const Number n)
 
void num_sech (Number ret, const Number n)
 
void num_csch (Number ret, const Number n)
 
void num_comp (Number ret, const Number n)
 
void num_bnot (Number ret, const Number n)
 
void num_band (Number ret, const Number n1, const Number n2)
 
void num_bxor (Number ret, const Number n1, const Number n2)
 
void num_bor (Number ret, const Number n1, const Number n2)
 
void num_trunc (Number ret, const Number n)
 
void num_unimplemented ()
 

Function Documentation

◆ init_numbers()

void init_numbers ( void  )

Definition at line 26 of file number.c.

References numbers_cleanup(), and randstate.

Referenced by main().

◆ is_int()

int is_int ( const Number  potential_int)

Definition at line 44 of file number.c.

References num_free(), num_init(), num_is_equal(), num_trunc(), and Number.

◆ num_abs()

void num_abs ( Number  ret,
const Number  n 
)

Definition at line 716 of file number.c.

References num_set_d(), and num_set_nan().

Referenced by uber_function().

◆ num_acos()

void num_acos ( Number  ret,
const Number  n 
)

Definition at line 336 of file number.c.

References num_set_d(), and num_set_nan().

Referenced by uber_function().

◆ num_acosh()

void num_acosh ( Number  ret,
const Number  n 
)

Definition at line 396 of file number.c.

References num_set_d(), and num_set_nan().

Referenced by uber_function().

◆ num_acoth()

void num_acoth ( Number  ret,
const Number  n 
)

Definition at line 416 of file number.c.

References num_is_zero(), num_set_d(), and num_set_nan().

Referenced by uber_function().

◆ num_acsch()

void num_acsch ( Number  ret,
const Number  n 
)

Definition at line 436 of file number.c.

References num_is_zero(), num_set_d(), and num_set_nan().

Referenced by uber_function().

◆ num_add()

void num_add ( Number  ret,
const Number  n1,
const Number  n2 
)

Definition at line 484 of file number.c.

References num_set_d(), and num_set_nan().

Referenced by simple_exp(), and uber_conversion().

◆ num_add_ui()

void num_add_ui ( Number  ret,
const Number  n,
const unsigned int  ui 
)

Definition at line 506 of file number.c.

References num_set_d(), and num_set_nan().

Referenced by uber_conversion().

◆ num_asech()

void num_asech ( Number  ret,
const Number  n 
)

Definition at line 426 of file number.c.

References num_is_zero(), num_set_d(), and num_set_nan().

Referenced by uber_function().

◆ num_asin()

void num_asin ( Number  ret,
const Number  n 
)

Definition at line 326 of file number.c.

References num_set_d(), and num_set_nan().

Referenced by uber_function().

◆ num_asinh()

void num_asinh ( Number  ret,
const Number  n 
)

Definition at line 386 of file number.c.

References num_set_d(), and num_set_nan().

Referenced by uber_function().

◆ num_atan()

void num_atan ( Number  ret,
const Number  n 
)

Definition at line 346 of file number.c.

References num_set_d(), and num_set_nan().

Referenced by uber_function().

◆ num_atanh()

void num_atanh ( Number  ret,
const Number  n 
)

Definition at line 406 of file number.c.

References num_set_d(), and num_set_nan().

Referenced by uber_function().

◆ num_band()

void num_band ( Number  ret,
const Number  n1,
const Number  n2 
)

Definition at line 815 of file number.c.

References num_get_ui(), num_set_nan(), and num_set_ui().

Referenced by simple_exp().

◆ num_bnot()

void num_bnot ( Number  ret,
const Number  n 
)

Definition at line 805 of file number.c.

References num_get_ui(), num_set_nan(), and num_set_ui().

Referenced by uber_function().

◆ num_bor()

void num_bor ( Number  ret,
const Number  n1,
const Number  n2 
)

Definition at line 837 of file number.c.

References num_get_ui(), num_set_nan(), and num_set_ui().

Referenced by simple_exp().

◆ num_bxor()

void num_bxor ( Number  ret,
const Number  n1,
const Number  n2 
)

Definition at line 826 of file number.c.

References num_get_ui(), num_set_nan(), and num_set_ui().

Referenced by simple_exp().

◆ num_cbrt()

void num_cbrt ( Number  ret,
const Number  n 
)

Definition at line 200 of file number.c.

References num_set_d(), and num_set_nan().

Referenced by uber_function().

◆ num_ceil()

void num_ceil ( Number  ret,
const Number  n 
)

Definition at line 584 of file number.c.

References num_set_d(), and num_set_nan().

Referenced by simple_exp(), and uber_function().

◆ num_cmp_si()

int num_cmp_si ( const Number  n,
const int  si 
)

Definition at line 726 of file number.c.

Referenced by uber_function().

◆ num_comp()

void num_comp ( Number  ret,
const Number  n 
)

Definition at line 795 of file number.c.

References num_set_d(), and num_set_nan().

Referenced by uber_function().

◆ num_const_catalan()

void num_const_catalan ( Number  n)

Definition at line 625 of file number.c.

References num_set_d().

Referenced by yylex().

◆ num_const_euler()

void num_const_euler ( Number  n)

Definition at line 620 of file number.c.

References num_set_d().

Referenced by yylex().

◆ num_const_pi()

void num_const_pi ( Number  n)

Definition at line 615 of file number.c.

References num_set_d().

Referenced by uber_function(), and yylex().

◆ num_cos()

void num_cos ( Number  ret,
const Number  n 
)

Definition at line 306 of file number.c.

References num_set_d(), and num_set_nan().

Referenced by num_sec(), and uber_function().

◆ num_cosh()

void num_cosh ( Number  ret,
const Number  n 
)

Definition at line 366 of file number.c.

References num_set_d(), and num_set_nan().

Referenced by num_sech(), and uber_function().

◆ num_cot()

void num_cot ( Number  ret,
const Number  n 
)

Definition at line 741 of file number.c.

References num_is_zero(), num_set_d(), and num_tan().

Referenced by uber_function().

◆ num_coth()

void num_coth ( Number  ret,
const Number  n 
)

Definition at line 768 of file number.c.

References num_is_zero(), num_set_d(), and num_tanh().

Referenced by uber_function().

◆ num_csc()

void num_csc ( Number  ret,
const Number  n 
)

Definition at line 759 of file number.c.

References num_is_zero(), num_set_d(), and num_sin().

Referenced by uber_function().

◆ num_csch()

void num_csch ( Number  ret,
const Number  n 
)

Definition at line 786 of file number.c.

References num_is_zero(), num_set_d(), and num_sinh().

Referenced by uber_function().

◆ num_div()

void num_div ( Number  ret,
const Number  n1,
const Number  n2 
)

Definition at line 528 of file number.c.

References num_set_d(), and num_set_nan().

Referenced by num_sinc(), simple_exp(), and uber_conversion().

◆ num_div_ui()

void num_div_ui ( Number  ret,
const Number  n,
const unsigned int  ui 
)

Definition at line 539 of file number.c.

References num_set_d(), and num_set_nan().

Referenced by num_to_str_complex(), and uber_function().

◆ num_exp()

void num_exp ( Number  ret,
const Number  n 
)

Definition at line 240 of file number.c.

References num_set_d(), and num_set_nan().

Referenced by uber_function().

◆ num_factorial()

void num_factorial ( Number  ret,
unsigned int  n 
)

Definition at line 250 of file number.c.

References num_set_nan().

Referenced by uber_function(), and yyparse().

◆ num_floor()

void num_floor ( Number  ret,
const Number  n 
)

Definition at line 574 of file number.c.

References num_set_d(), and num_set_nan().

Referenced by simple_exp(), and uber_function().

◆ num_free()

◆ num_get_d()

double num_get_d ( const Number  n)

Definition at line 446 of file number.c.

Referenced by num_to_str_complex(), print_this_result(), simple_exp(), and simpleCalc().

◆ num_get_default_prec()

num_prec_t num_get_default_prec ( )

Definition at line 479 of file number.c.

Referenced by display_prefs(), and WcalcController::setPrefs:.

◆ num_get_str()

char* num_get_str ( char *  str,
num_exp_t expptr,
const int  b,
const size_t  n,
const Number  op 
)

Definition at line 456 of file number.c.

References conf, _conf::dec_delimiter, malloc(), strchr, and strstrip().

Referenced by num_to_str_complex().

◆ num_get_ui()

unsigned int num_get_ui ( const Number  n)

Definition at line 451 of file number.c.

Referenced by num_band(), num_bnot(), num_bor(), num_bxor(), uber_function(), and yyparse().

◆ num_init()

◆ num_init_set()

void num_init_set ( Number  n1,
const Number  n2 
)

◆ num_init_set_d()

void num_init_set_d ( Number  n,
const double  d 
)

Definition at line 81 of file number.c.

References num_init().

Referenced by yylex().

◆ num_init_set_str()

int num_init_set_str ( Number  n,
const char *  str,
const int  base 
)

Definition at line 97 of file number.c.

References num_init(), and num_set_str().

Referenced by uber_conversion(), and yylex().

◆ num_init_set_ui()

void num_init_set_ui ( Number  n,
const unsigned int  ui 
)

Definition at line 89 of file number.c.

References num_init().

Referenced by main(), VariableList::newVariable:, simpleCalcInit(), yylex(), and yyparse().

◆ num_is_equal()

int num_is_equal ( const Number  n1,
const Number  n2 
)

Definition at line 665 of file number.c.

Referenced by is_int(), and simple_exp().

◆ num_is_greater()

int num_is_greater ( const Number  n1,
const Number  n2 
)

Definition at line 671 of file number.c.

Referenced by simple_exp().

◆ num_is_greaterequal()

int num_is_greaterequal ( const Number  n1,
const Number  n2 
)

Definition at line 677 of file number.c.

Referenced by simple_exp().

◆ num_is_inf()

int num_is_inf ( const Number  n)

Definition at line 655 of file number.c.

References isinf.

Referenced by num_to_str_complex(), and print_this_result().

◆ num_is_less()

int num_is_less ( const Number  n1,
const Number  n2 
)

Definition at line 683 of file number.c.

Referenced by simple_exp().

◆ num_is_lessequal()

int num_is_lessequal ( const Number  n1,
const Number  n2 
)

Definition at line 689 of file number.c.

Referenced by simple_exp().

◆ num_is_nan()

int num_is_nan ( const Number  n)

Definition at line 650 of file number.c.

Referenced by num_to_str_complex(), and print_this_result().

◆ num_is_zero()

◆ num_log()

void num_log ( Number  ret,
const Number  n 
)

Definition at line 286 of file number.c.

References num_set_d(), and num_set_nan().

Referenced by uber_function().

◆ num_log10()

void num_log10 ( Number  ret,
const Number  n 
)

Definition at line 266 of file number.c.

References num_set_d(), and num_set_nan().

Referenced by uber_function().

◆ num_log2()

void num_log2 ( Number  ret,
const Number  n 
)

Definition at line 276 of file number.c.

References num_set_d(), and num_set_nan().

Referenced by uber_function().

◆ num_mul()

void num_mul ( Number  ret,
const Number  n1,
const Number  n2 
)

Definition at line 151 of file number.c.

References num_set_d(), and num_set_nan().

Referenced by num_sqr(), simple_exp(), uber_conversion(), uber_function(), yylex(), and yyparse().

◆ num_mul_si()

void num_mul_si ( Number  ret,
const Number  n,
const int  si 
)

Definition at line 162 of file number.c.

References num_set_d(), and num_set_nan().

Referenced by uber_function(), and yyparse().

◆ num_mul_ui()

void num_mul_ui ( Number  ret,
const Number  n,
const unsigned int  ui 
)

Definition at line 173 of file number.c.

References num_set_d(), and num_set_nan().

Referenced by uber_function(), and yylex().

◆ num_neg()

void num_neg ( Number  ret,
const Number  n 
)

Definition at line 706 of file number.c.

References num_set_d(), and num_set_nan().

Referenced by uber_function().

◆ num_out_str()

void num_out_str ( FILE *  fd,
const int  base,
const Number  n 
)

Definition at line 630 of file number.c.

Referenced by yylex().

◆ num_pow()

void num_pow ( Number  ret,
const Number  n,
const Number  exp 
)

Definition at line 210 of file number.c.

References num_set_d(), and num_set_nan().

Referenced by simple_exp(), and yyparse().

◆ num_pow_si()

void num_pow_si ( Number  ret,
const Number  n,
const int  exp 
)

Definition at line 225 of file number.c.

References num_set_d(), and num_set_nan().

Referenced by uber_function().

◆ num_random()

int num_random ( Number  n)

Definition at line 594 of file number.c.

References num_set_d().

Referenced by uber_function(), and yylex().

◆ num_rint()

void num_rint ( Number  ret,
const Number  n 
)

Definition at line 550 of file number.c.

References num_set_d(), and num_set_nan().

Referenced by uber_function(), and yylex().

◆ num_rintz()

void num_rintz ( Number  ret,
const Number  n 
)

Definition at line 560 of file number.c.

References num_set_d(), and num_set_nan().

Referenced by simple_exp().

◆ num_sec()

void num_sec ( Number  ret,
const Number  n 
)

Definition at line 750 of file number.c.

References num_cos(), num_is_zero(), and num_set_d().

Referenced by uber_function().

◆ num_sech()

void num_sech ( Number  ret,
const Number  n 
)

Definition at line 777 of file number.c.

References num_cosh(), num_is_zero(), and num_set_d().

Referenced by uber_function().

◆ num_set()

◆ num_set_d()

◆ num_set_nan()

◆ num_set_str()

int num_set_str ( Number  n,
const char *  str,
const int  base 
)

Definition at line 125 of file number.c.

References Dprintf.

Referenced by num_init_set_str(), and simpleCalc().

◆ num_set_ui()

void num_set_ui ( Number  n,
const unsigned int  ui 
)

◆ num_sign()

int num_sign ( const Number  n)

Definition at line 695 of file number.c.

Referenced by num_to_str_complex(), and simple_exp().

◆ num_sin()

void num_sin ( Number  ret,
const Number  n 
)

Definition at line 296 of file number.c.

References num_set_d(), and num_set_nan().

Referenced by num_csc(), num_sinc(), and uber_function().

◆ num_sinc()

void num_sinc ( Number  ret,
const Number  n 
)

Definition at line 600 of file number.c.

References num_div(), num_is_zero(), num_set_d(), num_set_nan(), and num_sin().

Referenced by uber_function().

◆ num_sinh()

void num_sinh ( Number  ret,
const Number  n 
)

Definition at line 356 of file number.c.

References num_set_d(), and num_set_nan().

Referenced by num_csch(), and uber_function().

◆ num_sqr()

void num_sqr ( Number  ret,
const Number  n 
)

Definition at line 184 of file number.c.

References num_mul().

Referenced by yyparse().

◆ num_sqrt()

void num_sqrt ( Number  ret,
const Number  n 
)

Definition at line 190 of file number.c.

References num_set_d(), and num_set_nan().

Referenced by uber_function().

◆ num_sub()

void num_sub ( Number  ret,
const Number  n1,
const Number  n2 
)

Definition at line 495 of file number.c.

References num_set_d(), and num_set_nan().

Referenced by simple_exp(), and uber_conversion().

◆ num_sub_ui()

void num_sub_ui ( Number  ret,
const Number  n,
const unsigned int  ui 
)

Definition at line 517 of file number.c.

References num_set_d(), and num_set_nan().

Referenced by uber_conversion().

◆ num_tan()

void num_tan ( Number  ret,
const Number  n 
)

Definition at line 316 of file number.c.

References num_set_d(), and num_set_nan().

Referenced by num_cot(), and uber_function().

◆ num_tanh()

void num_tanh ( Number  ret,
const Number  n 
)

Definition at line 376 of file number.c.

References num_set_d(), and num_set_nan().

Referenced by num_coth(), and uber_function().

◆ num_trunc()

void num_trunc ( Number  ret,
const Number  n 
)

Definition at line 848 of file number.c.

References num_set_d(), and num_set_nan().

Referenced by is_int(), and simple_exp().

◆ num_unimplemented()

void num_unimplemented ( )

Definition at line 858 of file number.c.

◆ numbers_cleanup()

static void numbers_cleanup ( void  )
static

Definition at line 19 of file number.c.

Referenced by init_numbers().