-
-
Notifications
You must be signed in to change notification settings - Fork 589
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Previously we were using glibc's strtod function to parse floating point numbers. The problem is, strtod is locale dependent. Meaning 7,7 might be parsed as two numbers (7 and 7) in one locale, and parsed as one number (7 point 7) in another locale. This is undesirable. We need to set the locale to a value we know to make number parsing consistently. We could use setlocale(), but that is not thread-safe. We can also use uselocale(), which is thread-safe, but doesn't cover strtod (Yeah, some of the locale-aware functions only acknowledge the global locale, not the thread local one). So in frustration, I just wrote a simple floating point number parser myself. This parser obviously doesn't cover all cases strtod covers, but is good enough for our needs. Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
- Loading branch information
Showing
4 changed files
with
41 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters