modularml / mojo

The Mojo Programming Language
https://docs.modular.com/mojo/manual/
Other
23.1k stars 2.59k forks source link

[BUG] #3641

Open Fatihsigircik opened 1 week ago

Fatihsigircik commented 1 week ago

Bug description

`fn main() raises: var sonuc=topla(1.0004,.002) print(sonuc) var sonuc2=topla2(1.0004,.002) print(sonuc2) var sonuc3=topla3(1.0004,.002) print(sonuc3) var sonuc4=topla4(1.0004,.002) print(sonuc4)

def topla(x,y): return x+y

fn topla2(x:Float16,y:Float16)-> Float16: return x+y

fn topla3(x:Float32,y:Float32)-> Float32: return x+y

fn topla4(x:Float64,y:Float64)-> Float64: return x+y`


1.0024 1.001953125 1.0023999214172363 1.0024

Steps to reproduce

System information

- What OS did you do install Mojo on ?
- Provide version information for Mojo by pasting the output of `mojo -v`
- Provide Modular CLI version by pasting the output of `modular -v`
soraros commented 1 week ago

I fail to see the problem.

import numpy as np

a, b = 1.0004, 0.002
for dtype in [np.float16, np.float32, np.float64]:
  print(np.add(a, b, dtype=dtype))

Output:

1.002
1.0023999
1.0024