Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

Required fields*

6
  • A double is 64 bit, a floating is 32 bit. More precision means different rounding. Commented Aug 23, 2018 at 15:00
  • 2
    Not sure OP's question is about rational numbers though Commented Aug 23, 2018 at 15:04
  • I'm not sure why I'm being downvoted here. @MickyD that may be, but he's parsing a string to a double and a float based on the same string. The point is there is a least significant bit in any of these float-based number types that will cause rounding errors. I have a feeling if Op multiplied their result by a couple of factors of 10 then their answer would be equal. Commented Aug 23, 2018 at 15:44
  • Here's Microsoft's article explaining about how IEEE floating-point format works with rounding: learn.microsoft.com/en-us/cpp/build/reference/… Commented Aug 23, 2018 at 15:45
  • 1
    @obizues Not the downvoter, but the problem is with the , (culture), not exactly with the types used. Besides, multiplication can't be an answer: what will happen in the case of string ammount_in_string = 34028229999999999999999999999999999999.15? Multiplying by 10 will become an OverflowException Commented Aug 23, 2018 at 16:58