home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 7 / 07.iso / c / c065 / 2.ddi / CLIB2.ZIP / OSTRF.CPP < prev    next >
Encoding:
C/C++ Source or Header  |  1990-06-07  |  1.4 KB  |  45 lines

  1. /*-----------------------------------------------------------------------*
  2.  * filename - ostrf.cpp
  3.  * C++ stream floating-point I/O functions for handling ostreams
  4.  *-----------------------------------------------------------------------*/
  5.  
  6. /*[]------------------------------------------------------------[]*/
  7. /*|                                                              |*/
  8. /*|     Turbo C++ Run Time Library - Version 1.0                 |*/
  9. /*|                                                              |*/
  10. /*|                                                              |*/
  11. /*|     Copyright (c) 1990 by Borland International              |*/
  12. /*|     All Rights Reserved.                                     |*/
  13. /*|                                                              |*/
  14. /*[]------------------------------------------------------------[]*/
  15.  
  16. #include <stream.h>
  17.  
  18.  
  19. // write floating-point
  20. ostream& _Cdecl ostream::operator << ( double d )
  21. {
  22.     char b[64];
  23.     if( state < _fail ) {
  24.     register int count = sprintf(b, "%g", d);
  25.     register char *p = b;
  26.     while( count-- )
  27.         put(*p++);
  28.     }
  29.     return *this;
  30. }
  31.  
  32.  
  33. // write floating-point
  34. ostream& _Cdecl ostream::operator << ( long double d )
  35. {
  36.     char b[64];
  37.     if( state < _fail ) {
  38.     register int count = sprintf(b, "%Lg", d);
  39.     register char *p = b;
  40.     while( count-- )
  41.         put(*p++);
  42.     }
  43.     return *this;
  44. }
  45.