Always false float comparisons

Joseph Rushton Wakeling via Digitalmars-d digitalmars-d at puremagic.com
Wed May 18 04:12:16 PDT 2016


On Wednesday, 18 May 2016 at 09:21:30 UTC, Ola Fosheim Grøstad 
wrote:
> No. The "const float y" will not be coerced to 32 bit, but the 
> "float y" will be coerced to 32 bit. So you get two different y 
> values. (On a specific compiler, i.e. DMD.)

I'm not sure that the `const float` vs `float` is the difference 
per se.  The difference is that in the examples you've given, the 
`const float` is being determined (and used) at compile time.

But a `const float` won't _always_ be determined or used at 
compile time, depending on the context and manner in which the 
value is set.

Let's be clear about the problem -- compile time vs. runtime, 
rather than `const` vs non-`const`.


More information about the Digitalmars-d mailing list