home *** CD-ROM | disk | FTP | other *** search
/ The C Users' Group Library 1994 August / wc-cdrom-cusersgrouplibrary-1994-08.iso / listings / v_11_02 / 1102056a < prev    next >
Text File  |  1992-12-07  |  2KB  |  73 lines

  1. /*****************************************************
  2.          File Name: FINANCES.H
  3.          Description: Include file for FINANCES.C
  4.          Portability: Standard C
  5. ******************************************************/
  6.  
  7. #if !defined ( FINANCES_DEFINED )
  8.  
  9.    /* Prototypes for function in FINANCES.C */
  10.    double a_to_f( double i, int n );
  11.    double a_to_f_c( double r, int n );
  12.    double a_to_p( double i, int n );
  13.    double a_to_p_c( double r, int n );
  14.    double f_to_a( double i, int n );
  15.    double f_to_a_c( double r, int n );
  16.    double f_to_p( double i, int n );
  17.    double f_to_p_c( double r, int n );
  18.    double p_to_a( double i, int n );
  19.    double p_to_a_c( double r, int n );
  20.    double p_to_f( double i, int n );
  21.    double p_to_f_c( double r, int n );
  22.  
  23.    /* Natural log base */
  24.    #define LN_BASE 2.718281828459
  25.  
  26.    /* Macro versions of functions in FINANCES.C */
  27.    #define A_TO_F( i, n ) \
  28.       ( ( pow( 1.0 + i, n ) - 1.0 ) / i )
  29.  
  30.    #define A_TO_F_C( r, n ) \
  31.       ( ( pow( LN_BASE, r * n ) - 1.0 ) / \
  32.       ( pow( LN_BASE, r ) - 1.0 ) )
  33.  
  34.    #define A_TO_P( i, n ) \
  35.       ( ( pow( 1.0 + i, n ) - 1.0 ) / \
  36.       ( i * pow( 1.0 + i, n ) ) )
  37.  
  38.    #define A_TO_P_C( r, n ) \
  39.       ( ( 1.0 - pow( LN_BASE, -( r * n ) ) ) / \
  40.       ( pow( LN_BASE, r ) - 1.0 ) )
  41.  
  42.    #define F_TO_A( i, n ) \
  43.       ( i / ( pow( 1.0 + i, n ) - 1.0 ) )
  44.  
  45.    #define F_TO_A_C( r, n ) \
  46.       ( ( pow( LN_BASE, r ) - 1.0 ) / \
  47.       ( pow( LN_BASE, r * n ) - 1.0 ) )
  48.  
  49.    #define F_TO_P( i, n ) \
  50.       ( 1.0 / pow( 1.0 + i, n ) )
  51.  
  52.    #define F_TO_P_C( r, n ) \
  53.       ( 1.0 / pow( LN_BASE, r * n ) )
  54.  
  55.    #define P_TO_A( i, n ) \
  56.       ( i * pow( 1.0 + i, n ) / \
  57.       ( pow( 1.0 + i, n ) - 1.0 ) )
  58.  
  59.    #define P_TO_A_C( r, n ) \
  60.       ( ( pow( LN_BASE, r ) - 1.0 ) / \
  61.       ( 1.0 - pow( LN_BASE, -( r * n ) ) ) )
  62.  
  63.    #define P_TO_F( i, n ) \
  64.       ( pow( 1.0 + i, n ) )
  65.  
  66.    #define P_TO_F_C( r, n ) \
  67.       ( pow( LN_BASE, r * n ) )
  68.  
  69. #endif
  70.  
  71.  
  72.  
  73.