home *** CD-ROM | disk | FTP | other *** search
/ Tricks of the Windows Gam…ming Gurus (2nd Edition) / Disc2.iso / vc98 / crt / src / xstod.c < prev    next >
C/C++ Source or Header  |  1998-06-16  |  879b  |  38 lines

  1. /* _Stod/_Stof/_Stold functions for Microsoft */
  2. #include <stdlib.h>
  3. #include "wctype.h"
  4. #ifndef _LIMITS
  5. #include <yvals.h>
  6. #endif
  7. _STD_BEGIN
  8.  
  9. _CRTIMP2 double _Stod(const char *s, char **endptr, long pten)
  10.     {    /* convert string to double */
  11.     double x = strtod(s, endptr);
  12.     for (; 0 < pten; --pten)
  13.         x *= 10.0;
  14.     for (; pten < 0; ++pten)
  15.         x /= 10.0;
  16.     return (x);
  17.     }
  18.  
  19. _CRTIMP2 float _Stof(const char *s, char **endptr, long pten)
  20.     {    /* convert string to float */
  21.     return ((float)_Stod(s, endptr, pten));
  22.     }
  23.  
  24. _CRTIMP2 long double _Stold(const char *s, char **endptr, long pten)
  25.     {    /* convert string to long double */
  26.     return ((long double)_Stod(s, endptr, pten));
  27.     }
  28. _STD_END
  29.  
  30. /*
  31.  * Copyright (c) 1995 by P.J. Plauger.  ALL RIGHTS RESERVED. 
  32.  * Consult your license regarding permissions and restrictions.
  33.  */
  34.  
  35. /*
  36. 951207 pjp: added new file
  37.  */
  38.