A couple of locale fixes

git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@17167 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
CaS 2003-07-07 09:05:53 +00:00
parent ec7af312f4
commit 14577e9418
6 changed files with 229 additions and 14 deletions

View file

@ -2425,14 +2425,40 @@ handle_printf_atsign (FILE *stream,
return [self intValue] != 0 ? YES : NO;
}
extern BOOL GSScanDouble(unichar*, unsigned, double*);
/**
* Returns the strings content as a double. Skips leading whitespace.<br />
* Conversion is not localised (ie uses '.' as the decimal separator).<br />
* Returns 0.0 on underflow or if the string does not contain a number.
*/
- (double) doubleValue
{
return atof([self lossyCString]);
unichar buf[32];
unsigned len = [self length];
double d = 0.0;
if (len > 32) len = 32;
[self getCharacters: buf range: NSMakeRange(0, len)];
GSScanDouble(buf, len, &d);
return d;
}
/**
* Returns the strings content as a double. Skips leading whitespace.<br />
* Conversion is not localised (ie uses '.' as the decimal separator).<br />
* Returns 0.0 on underflow or if the string does not contain a number.
*/
- (float) floatValue
{
return (float) atof([self lossyCString]);
unichar buf[32];
unsigned len = [self length];
double d = 0.0;
if (len > 32) len = 32;
[self getCharacters: buf range: NSMakeRange(0, len)];
GSScanDouble(buf, len, &d);
return (float)d;
}
- (int) intValue