Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

A smart compiler should be able to figure out a better value for 0/0, depending on context.

For example:

    for i in range(0, 10):
        print(i/0.0)
In this case it should probably print +inf when i == 0.

But:

    for i in range(-10, 10):
        print(i/0.0)
Now it is not clear, but at least we know it's an infinity so perhaps we need a special value +-inf.

And:

    for i in range(-10, 10):
        print(i/i)
In this case, the value for 0/0 can be 1.


Well, it could, but that would be against the spec. The hardware implements IEEE 754, most languages guarantee IEEE 754, and transforming code so that 0.0/0.0 doesn't result in NaN would be invalid.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: