Leaked source code of windows server 2003
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

53 lines
1.2 KiB

  1. /***
  2. * istrflt.cpp - definitions for istream operator>>(float) member function
  3. *
  4. * Copyright (c) 1991-2001, Microsoft Corporation. All rights reserved.
  5. *
  6. *Purpose:
  7. * Definitions of operator>>(float) member function for istream class.
  8. * [AT&T C++]
  9. *
  10. *Revision History:
  11. * 09-26-91 KRS Created. Split out from istream.cxx for granularity.
  12. * 12-30-92 KRS Fix indirection problem with **endptr.
  13. * 06-14-95 CFW Comment cleanup.
  14. *
  15. *******************************************************************************/
  16. #include <cruntime.h>
  17. #include <internal.h>
  18. #include <stdlib.h>
  19. #include <float.h>
  20. #include <iostream.h>
  21. #pragma hdrstop
  22. #pragma check_stack(on) // large buffer(s)
  23. #define MAXFLTSIZ 20
  24. istream& istream::operator>>(float& n)
  25. {
  26. _WINSTATIC char ibuffer[MAXFLTSIZ];
  27. double d;
  28. char ** endptr = (char**)NULL;
  29. if (ipfx(0))
  30. {
  31. if (getdouble(ibuffer, MAXFLTSIZ)>0)
  32. {
  33. d = strtod(ibuffer, endptr);
  34. if (d > FLT_MAX)
  35. n = FLT_MAX;
  36. else if (d < -FLT_MAX)
  37. n = -FLT_MAX;
  38. else if ((d>0) && (d< FLT_MIN))
  39. n = FLT_MIN;
  40. else if ((d<0) && (d> -FLT_MIN))
  41. n = - FLT_MIN;
  42. else
  43. n = (float) d;
  44. }
  45. isfx();
  46. }
  47. return *this;
  48. }