On Wednesday, 23 July 2014 at 07:49:28 UTC, Don wrote:
I think it's a complete fantasy to think you can write generic code that will work for both floats and ints. The algorithms are completely different.

Not really a valid line of reasoning.

Bool < uints < ints < fixed point < floats < interval arithmetic

You can make the same argument about all these types. Moreover, any float can be accurately represented as a rational number.

(f + 1) and  (i +  1)  have totally different semantics.

Not if you view floats as a single sample on a real interval. You can compute this interval on CT and sample a float on it.

If you are speaking of iterative methods, sure, it might not converge. But that us not unique for floats, happens with ints vs uints too.

Well, it's not a small number of differences. Almost every operation is different. Maybe all of them. I can't actually think of a single operation where the semantics are the same for integers and floating point.

Double can emulate 32 bit ints. Fixed point is essentially subnormal floats with limited exponent. Fixed point IS integer math. All int types are fixed point. If you find a clean way to support transaparent use of fixed point, you probably also resolve the issues with floats.

I think that unfortunately, it's a quest that is doomed to fail. Producing generic code that works for both floats and ints is a fool's errand.

Of course not. Not if the semantic analysis deals with precision and value ranges. Not trivial, but not impossible either.

Reply via email to