Skip to content

Feature/sprintf fix - #3253

Closed
hroest wants to merge 4 commits into
OpenMS:feature/qt5from
hroest:feature/sprintf_fix
Closed

hroest wants to merge 4 commits into
OpenMS:feature/qt5from
hroest:feature/sprintf_fix

Conversation

@hroest

@hroest hroest commented Feb 16, 2018

Copy link
Copy Markdown
Contributor

use boost::format instead of sprintf

@hroest hroest mentioned this pull request Feb 16, 2018
apex = boost::str(boost::format("%f") % sub_it->getMetaValue("peak_apex_int"));
}
os << line << meta_values << (String)intensity_char << "\t" << apex << "\t" << (String)sub_it->getMetaValue("native_id") << "\t" << (String)mz_char << std::endl;
os << line << meta_values << intensity_area << "\t" << apex << "\t" << (String)sub_it->getMetaValue("native_id") << "\t" << mz_str << std::endl;

@timosachsenberg timosachsenberg Feb 20, 2018 •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

maybei its sufficient to use
os.imbue(std::locale("En_US"));
and directly write out floats / ints using the regular stream

@jpfeuffer

Copy link
Copy Markdown
Contributor

I always thought it was important that the length was 40 chars and that is why sprintf was used.
In that case we could just use our toString method for metavalues. This always worked for me locale independent.

@timosachsenberg

Copy link
Copy Markdown
Contributor

Ok that's interesting. So the C++ locale does not have the problem? Fine with me if that works

@hroest hroest mentioned this pull request Feb 24, 2018
@hroest

hroest commented Feb 24, 2018

Copy link
Copy Markdown
Contributor Author

no 40 chars is not really important ...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants