I get why float32 can auto convert to float64... there is no loss in precision.

But its strange to me that reverse is also true. Nim will auto convert a 
float64 to a float32 and loose precision!!! Silently! This is not true for ints.

Here it states so in the manual: 
[https://nim-lang.org/docs/manual.html#type-relations-convertible-relation](https://nim-lang.org/docs/manual.html#type-relations-convertible-relation)
    
    
    var
      a: float64 = 20e-70
      b: float32 = a
      c: float64 = b
    
    echo a
    echo b
    echo c
    
    
    Run

Output:
    
    
    2e-69
    0.0
    0.0
    
    
    Run

You can see here we had float64 of 20e-70 go through an intermediate float32 
that rounded it, so that the next float64 was 0.

My fear that its easy to have a random float32 in your code that is basically a 
rounding function. And you will never know!

Thoughts? Why was it done like this? Do you guys think this is good? Does it 
matter? Can't change now because too much code depends on it?

Reply via email to