home *** CD-ROM | disk | FTP | other *** search
/ Media Share 9 / MEDIASHARE_09.ISO / progmisc / nfsrc21.zip / E2D.PRG < prev    next >
Text File  |  1991-08-16  |  2KB  |  74 lines

  1. /*
  2.  * File......: E2D.PRG
  3.  * Author....: Gary Baren
  4.  * CIS ID....: 75470,1027
  5.  * Date......: $Date:   15 Aug 1991 23:03:28  $
  6.  * Revision..: $Revision:   1.2  $
  7.  * Log file..: $Logfile:   E:/nanfor/src/e2d.prv  $
  8.  *
  9.  * This is an original work by Gary Baren and is hereby placed in the
  10.  * public domain.
  11.  *
  12.  * Modification history:
  13.  * ---------------------
  14.  *
  15.  * $Log:   E:/nanfor/src/e2d.prv  $
  16.  * 
  17.  *    Rev 1.2   15 Aug 1991 23:03:28   GLENN
  18.  * Forest Belt proofread/edited/cleaned up doc
  19.  * 
  20.  *    Rev 1.1   14 Jun 1991 19:51:40   GLENN
  21.  * Minor edit to file header
  22.  * 
  23.  *    Rev 1.0   07 Jun 1991 23:03:32   GLENN
  24.  * Initial revision.
  25.  *  
  26.  */
  27.  
  28.  
  29. /*  $DOC$
  30.  *  $FUNCNAME$
  31.  *     FT_E2D()
  32.  *  $CATEGORY$
  33.  *     Conversion
  34.  *  $ONELINER$
  35.  *        Convert scientific notation string to a decimal
  36.  *  $SYNTAX$
  37.  *        FT_E2D( <cNumE> )  -> <nDec>
  38.  *  $ARGUMENTS$
  39.  *        <cNumE>   Scientific notation string to convert
  40.  *  $RETURNS$
  41.  *        <nDec>    Decimal number
  42.  *  $DESCRIPTION$
  43.  *        Given a string in the format  x.yEz, the decimal 
  44.  *        equivalent is returned.
  45.  *  $EXAMPLES$
  46.  *        ? FT_E2D( "1.23E1" )
  47.  *          -> 12.3
  48.  *
  49.  *        ? FT_E2D( "-1.235E1" )
  50.  *          -> -12.35
  51.  *
  52.  *        ? ft_d2e( "5.43E-6" )
  53.  *          -> 0.0000543
  54.  *  $SEEALSO$
  55.  *    FT_D2E()
  56.  *  $END$
  57.  */
  58.  
  59. #ifdef FT_TEST
  60.   function main( sNumE )
  61.      return qout( FT_E2D( sNumE ) )
  62. #endif
  63.  
  64. function ft_e2d( sNumE )
  65.   local nMant, nExp
  66.  
  67.   nMant := val( left( sNumE, at( 'E', sNumE ) - 1 ) )
  68.   nExp  := val(substr( sNumE,                    ;
  69.                  at( 'E', sNumE ) + 1,           ;
  70.                  len( sNumE ) - at( 'E', sNumE ) ;
  71.                      )                           ;
  72.               )
  73.   return( nMant * 10 ^ nExp )
  74.