diff options
Diffstat (limited to 'MLKDoubleFloat.m')
-rw-r--r-- | MLKDoubleFloat.m | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/MLKDoubleFloat.m b/MLKDoubleFloat.m index 98daa09..e3cb94d 100644 --- a/MLKDoubleFloat.m +++ b/MLKDoubleFloat.m @@ -16,12 +16,16 @@ * along with this program. If not, see <http://www.gnu.org/licenses/>. */ +#define _XOPEN_SOURCE 600 // strtof (not actually needed here) + #import "MLKSingleFloat.h" #import "MLKDoubleFloat.h" #import <Foundation/NSString.h> #include <stdio.h> +#include <stdlib.h> +#include <locale.h> @implementation MLKDoubleFloat @@ -32,6 +36,13 @@ exponentNegative:(BOOL)exponentNegative { self = [super init]; + char *locale; + + // FIXME: This is probably not thread-safe. + locale = setlocale (LC_NUMERIC, NULL); + setlocale (LC_NUMERIC, "C"); + + // strtod or sscanf -- is there a difference? sscanf ([[NSString stringWithFormat:@"%c%@.%@e%c%@", (negative ? '-' : '+'), intPart, @@ -41,6 +52,9 @@ UTF8String], "%lf", &value); + + setlocale (LC_NUMERIC, locale); + return self; } @@ -117,4 +131,9 @@ return [NSString stringWithFormat:@"%@d0",str]; } + +-(NSString *) descriptionForLisp +{ + return [self description]; +} @end |