Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixes nasty bug when locale means , is used for decimal point #468

Merged
merged 2 commits into from
Oct 21, 2021

Conversation

neworderofjamie
Copy link
Contributor

No idea how no one has encountered this before but, turns out, as well as truncating floating point point numbers, std::to_string also formats them according to the current locale which may include using "," as a decimal point, leading to constants which the compiler doesn't understand. ModelSpec::scalarExpr is the one place where std::to_string is used for printing floating point so simple fix was to change this to use Utils::writePreciseString (I also fixed a warning in the tests)

… than ``std::string`` both because it's correct and, specifically, because it ignores locales
@neworderofjamie neworderofjamie added this to the GeNN 4.6.0 milestone Oct 21, 2021
Copy link
Member

@tnowotny tnowotny left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Definitely the right thing to do. Using std::to_string appears to be a bad idea overall. It is clearly made for a very different purpose.

@neworderofjamie neworderofjamie merged commit 2684e4d into master Oct 21, 2021
@neworderofjamie neworderofjamie deleted the locale branch October 21, 2021 10:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants