ceylon / ceylon-spec

DEPRECATED
Apache License 2.0
108 stars 34 forks source link

hexadecimal/binary floating point literals #990

Open gavinking opened 10 years ago

gavinking commented 10 years ago

I wonder if we should after all support floating point literals in bases other than 10. I guess this can be useful for some very technical floating-point stuff, like, for example:

Float minInteger = -$1.0p63;
Float maxInteger = $1.0p63 - 1;
Float minFloat = $1.0p-1022;
Float maxFloat = ($2.0 - $1.0p-52) * $1.0p+21023;

I note, however, that I have never once, in my whole career, used such a thing nor seen it used. Perhaps if we ever decide to implement ceylon.math in Ceylon, we might find one or two places to use it?

Anyway, if anyone knows of a use for these, please let me know.

FroMage commented 10 years ago

I don't think that's useful at all. If anything, I suppose that people who want floating point literals in binary are going to want to type them in binary itself (that is, in the binary encoding for floating point, not in the binary base). I've never heard of floating points in hexa.

gavinking commented 10 years ago

Java supports this. That's the only reason I raised it.

FroMage commented 10 years ago

That's interesting. We should unearth the discussion that led to them supporting it, if it exists.