Skip to content

Float is rounded to nearest int value #514

@masrul

Description

@masrul

Hello,
My XML file has something like that,

     <Bond class1="OW" class2="HW" length="0.09572" forceconst="502080.7"/>

In my c++ code,

 float bond_fc = bond_type.attribute("forceconst").as_float();  // just relevant line 

I expect bond_fc to be 502080.7, but it is 502081. Looks like strtod is responsible for that. I wonder how to avoid this unwanted rounding to the nearest int value.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions