mirror of
https://github.com/glest/glest-source.git
synced 2025-08-13 20:03:58 +02:00
- ensure locale is properly set when converting numbers
This commit is contained in:
@@ -117,12 +117,16 @@ string intToHex(int i){
|
|||||||
}
|
}
|
||||||
|
|
||||||
string floatToStr(float f,int precsion) {
|
string floatToStr(float f,int precsion) {
|
||||||
|
setlocale(LC_NUMERIC, "C");
|
||||||
|
|
||||||
char str[strSize]="";
|
char str[strSize]="";
|
||||||
snprintf(str, strSize-1, "%.*f", precsion,f);
|
snprintf(str, strSize-1, "%.*f", precsion,f);
|
||||||
return (str[0] != '\0' ? str : "");
|
return (str[0] != '\0' ? str : "");
|
||||||
}
|
}
|
||||||
|
|
||||||
string doubleToStr(double d,int precsion) {
|
string doubleToStr(double d,int precsion) {
|
||||||
|
setlocale(LC_NUMERIC, "C");
|
||||||
|
|
||||||
char str[strSize]="";
|
char str[strSize]="";
|
||||||
snprintf(str, strSize-1, "%.*f", precsion,d);
|
snprintf(str, strSize-1, "%.*f", precsion,d);
|
||||||
return (str[0] != '\0' ? str : "");
|
return (str[0] != '\0' ? str : "");
|
||||||
|
Reference in New Issue
Block a user