- ensure locale is properly set when converting numbers

This commit is contained in:
Mark Vejvoda 2011-12-01 18:49:30 +00:00
parent c86c506c2d
commit d8f4c69a01

View File

@ -117,12 +117,16 @@ string intToHex(int i){
}
string floatToStr(float f,int precsion) {
setlocale(LC_NUMERIC, "C");
char str[strSize]="";
snprintf(str, strSize-1, "%.*f", precsion,f);
return (str[0] != '\0' ? str : "");
}
string doubleToStr(double d,int precsion) {
setlocale(LC_NUMERIC, "C");
char str[strSize]="";
snprintf(str, strSize-1, "%.*f", precsion,d);
return (str[0] != '\0' ? str : "");