home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 7 / 07.iso / c / c160 / 1.ddi / SOURCE / F4DOUBLE.C < prev    next >
Encoding:
C/C++ Source or Header  |  1990-06-22  |  1.2 KB  |  58 lines

  1.  
  2. /* (c)Copyright Sequiter Software Inc., 1987-1990.  All rights reserved.
  3.  
  4.    f4double.c
  5. */
  6.  
  7. /* f4double
  8.  
  9.    Returns the value of the corresponding field as a double.
  10.    Only defined for 'Numeric' fields and 'Character' fields
  11.    containing numeric data.
  12. */
  13.  
  14. #include "d4base.h"
  15. #include "string.h"
  16. #include "p4misc.h"
  17.  
  18. extern int  v4cur_base ;
  19. extern BASE *v4base ;
  20.  
  21. double  f4double( long f_ref )
  22. {
  23.    if ( f4type(f_ref) == 'D' )
  24.    {
  25.       double d ;
  26.  
  27.       c4dt_julian( f4ptr(f_ref), &d) ;
  28.       return( d ) ;
  29.    }
  30.  
  31.    /* Convert the field data into a 'double' */
  32.    return( c4atod( f4ptr(f_ref), f4width(f_ref))  ) ;
  33. }
  34.  
  35. void f4r_double( long f_ref, double d_value )
  36. {
  37.    char *ptr ;
  38.  
  39.    if ( f4type(f_ref) == 'D' )
  40.    {
  41.       c4dt_str( f4ptr(f_ref), &d_value ) ;
  42.    }
  43.    else
  44.    {
  45.       /* Convert the 'double' to ASCII and then copy it into the record buffer. */
  46.       ptr =  c4dtoa( d_value, f4width(f_ref), f4decimals(f_ref) ) ;
  47.       memcpy( f4ptr(f_ref), ptr, (size_t) f4width(f_ref) ) ;
  48.    }
  49.  
  50.    if ( v4base[v4cur_base].eof == 0 )     d4ptr()->buffer_changed =  1 ;
  51. }
  52.  
  53. double f4value( long f_ref)
  54. {
  55.    return( f4double(f_ref) ) ;
  56. }
  57.  
  58.