Thread Links | Date Links | ||||
---|---|---|---|---|---|
Thread Prev | Thread Next | Thread Index | Date Prev | Date Next | Date Index |
On 7/9/2013 9:11 AM, Vincent Lefevre
wrote:
On 2013-07-09 11:32:37 -0400, Michel Hack wrote:Replying to Dima, Vincent wrote:Arbitrary precision library is not a trouble. Conversion of decimal string to binary floating-point with correct rounding already requires arbitrary precision library.Multiple precision, yes. But arbitrary precision is not necessary, as the needed precision is bounded, AFAIK.True for decimal string input (max precision needed for binary64 is less than 800 digits), but it gets tricky for rational input, which was the actual context here.That's precisely why I wondered whether there could be a limit for integers in the context of rational literals. At the risk of oversimplifying from a language perspective, I see two possibilities here. 1. Lisp has arbitrary precision integers and rational numbers, and so there is no need for special treatment to provide input of exact rationals of any size. There are other languages with similar capabilities directly or via libraries. In that case, use them with e.g. double_nums2interval(). These systems all must have some resolution of the problem of how to represent internally, read and write such numbers, and how to reduce to lowest terms, convert to nearest floats, perhaps rounding up/down, etc. 2. Otherwise allow input of any two integers in the host language, and produce a tight interval around their ratio. e.g. double_integerpair2int(num,denom). This eliminates the need to specify treatment of strings of decimal digits of huge length, which as has been pointed out, could be used to represent well known numbers wastefully. e.g. 1/2 could be 1...<1000 digits, all zero> / 2...<1000 digits all zero>. Of course there are many rational numbers that are representable as floats that do not correspond to some +- <int_64>/<int_64>, and if you really find that too much of a restriction, that's a problem. I don't find that to be a problem, but then my favorite language has arbitrary precision integers and rationals anyway. If you find a need to represent numbers smaller than 2^-64 or larger than 2^64, (roughly 5.4e-20 and 1.8e19), or need more bits of precision near the edges of that range, some kind of scaling could be implemented, but that might strike people as clumsy. Just a guess. Anyway specifying two integers in the host language makes the standard statement much simpler. RJF |