Re: Strange double to uint conversion

2019-11-19 Thread Luiz Silveira via Digitalmars-d-learn
On Monday, 18 November 2019 at 21:54:53 UTC, Steven Schveighoffer wrote: You are expecting floating point to behave as if it is stored as a decimal number. It's not. I was actually asking why 'c' and 'c2' functions behave differently. After mipri's answer I learned that the default floating

Re: Strange double to uint conversion

2019-11-18 Thread Luiz Silveira via Digitalmars-d-learn
On Monday, 18 November 2019 at 21:14:37 UTC, mipri wrote: double f; If this is changed to `real f;`, you get the desired result. real is also the type used for the comparison code: https://dlang.org/spec/float.html#fp_const_folding Yes, it worked as expected. Thank you, Luiz.

Strange double to uint conversion

2019-11-18 Thread Luiz Silveira via Digitalmars-d-learn
Hello, everyone! I'm a new D fan, still learning the language and this is my first post. I came up with a strange behavior, using D 2.089 for windows. Considering the program "error.d": import std.stdio; import std.conv; void main() { uint c(double v) { return