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

  1. /*-----------------------------------------------------------------------*
  2.  * filename - bcd2.cpp
  3.  *-----------------------------------------------------------------------*/
  4.  
  5. /*[]------------------------------------------------------------[]*/
  6. /*|                                                              |*/
  7. /*|     Turbo C++ Run Time Library - Version 1.0                 |*/
  8. /*|                                                              |*/
  9. /*|                                                              |*/
  10. /*|     Copyright (c) 1990 by Borland International              |*/
  11. /*|     All Rights Reserved.                                     |*/
  12. /*|                                                              |*/
  13. /*[]------------------------------------------------------------[]*/
  14.  
  15. #ifndef __cplusplus
  16. #error Must use C++ for the type bcd.
  17. #endif
  18.  
  19. #include "bcd.h"
  20.  
  21. // Stream I/O function definitions
  22.  
  23. ostream& pascal operator<<(ostream& s, bcd& a)
  24. {
  25.     return s << real(a);
  26. }
  27.  
  28. istream& pascal operator>>(istream& s, bcd& a)
  29. {
  30.     long double x;
  31.     s >> x;
  32.     a = bcd(x);
  33.     return s;
  34. }
  35.  
  36. /*
  37. These don't work, unless the bcd rep is unique.
  38.  
  39. inline int operator==(bcd& a, bcd& b)
  40. {
  41.     return a.mantissa[0] == b.mantissa[0]
  42.         && a.mantissa[1] == b.mantissa[1] && a.expo == b.expo;
  43. }
  44.  
  45. inline int operator!=(bcd& a, bcd& b)
  46. {
  47.     return a.mantissa[0] != b.mantissa[0]
  48.         || a.mantissa[1] != b.mantissa[1] || a.expo != b.expo;
  49. }
  50. */
  51.