home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 7 / 07.iso / c / c082_144 / 1.ddi / CLIBSRC.ZIP / BCD2.CPP < prev    next >
Encoding:
C/C++ Source or Header  |  1992-06-10  |  1.1 KB  |  50 lines

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