Thread Links | Date Links | ||||
---|---|---|---|---|---|
Thread Prev | Thread Next | Thread Index | Date Prev | Date Next | Date Index |
RF> IEEE754 single 0.1 means exactly 13421773/134217728 or about 0.1000000014901... or
On 6/9/2013 8:40 AM, Jürgen Wolff von Gudenberg wrote: > You don't like 0.1 changing its meaning when you put string quotes > round it, so what about when you put square brackets round? I am uncomfortable with both "0.1" and [0.1]. I am happier with 1/10 or ratio(1,10), since the semantics of these are easier to explain. Even ratio(0,0), ratio(1,0) ratio(-1,0). Perhaps an intermediate version could be fashioned with something which so surrounds the 0.1 that it is hard to confuse. Like IEEE754_binary_double_interval_containing_decimal("0.1") I understand the motive to support a hypothetical "mathematician" computer user who doesn't do scientific computation in the ordinary way and/or is ignorant of representation issues in floating-point computation. This person might use an interactive interval-based system to construct a proof or validate an algorithm. (Rather than say, estimate the intensity of a tornado.) Such a relatively "pure" mathematician might not understand (or need to understand) that 0.1 cannot be represented exactly in binary, even though binary is (probably) the underlying representation for floats in the user's computer. For such a person, in such a system, 0.1 meaning exactly 1/10 makes perfect sense. Unfortunately if that interactive system is not solely about intervals but allows that user to set x=0.1 outside the interval system, there is a potential difficulty. IEEE754 single 0.1 means exactly 13421773/134217728 or about 0.1000000014901... or 1/10+ 1.49..e-9. and if the default for creating an interval around 0.1 is to use double precision by [0.1] or "0.1" then one gets an interval equivalent to [3602879701896396/36028797018963968, 3602879701896397/36028797018963968] or approximately [0.099999999999999977795.. , 0.10000000000000000555..] or 1/10 + [-2.22...e-17, 5.55..e-18] The odd situation here is that the ordinary computer single precision number 0.1 mentioned previously is not contained in that interval [0.1]. Thus we have a situation in which a naive user stepping outside the interval package to read or compute a scalar number possibly encounters a violation of containment. From a programming language perspective, this is not so comfortable. Certainly the same issue comes up if the single-precision computer number 0.1 is not in the interval double_interval(1/10,1/10). But I think it is easier to explain that 0.1 converted to binary is not exactly the same as 1/10, and 0.10000000149.. is greater than 1/10. Easier than to explain that 0.1 is not in [0.1]. I hope that text2interval is not so intertwined with other considerations of the standard that it can be "optionalized" without too much difficulty. It doesn't seem that text2interval is needed for a Lisp implementation, but that may not be "typical". RJF |