From: Stephen W. <sw...@sw...> - 2004-01-19 23:59:00
|
> Is the definition of "too large" any number larger than the largest > exactly representable number? Here's what's in the last paragraph of E.1 that Andreas referred to: Once overloading resolution has determined the type of a special constant, it is a compile-time error if the constant does not make sense or does not denote a value within the machine representation chosen for the type. "too large" was a poor choice of words on my part -- a better choice would have been "not within the machine representation". Now, the problem is the meaning of within. If one interprets it as in the total order sense, then maybe it makes sense to choose either maxFinite or posInf for 1E1000. But one could take a stricter interpretation and say that 1E1000 doesn't exactly denote any floating point number, and so an error should be reported. Actually, one could take this view further and say that unless the real constant unambiguously denotes a particular floating point representation, then it should be rejected, although that seems a bit extreme to me. In any case, I think it's fair to say that the Definition isn't clear one way or the other, since it doesn't define what real constants denote and it doesn't define what floating point bits represent (points or ranges). Since the Definition is unclear, I think we should consider what would be most helpful to a programmer. Under that criterion, I think a programmer would find it most helpful to be informed at compile time if a real constant that he writes down is not finite, rather than not finding out until run time, or possibly not at all. After all, if the programmer meant to get an infinity, he would have written Real.posInf. Thus, I think the right thing is to take Real.fromString of the constant, and report a compile-time error if the result is not finite. |