strange behaviour with simple decimals



If you think that by hiding some number of digits in output you will 
avoid all differences between decimal and binary,
I think you will be disappointed. The examples that illustrate the 
"strange" behavior will be less common, but they will exist and be, in 
some sense, even harder to explain.

If you wish to experiment with a maxima that does not use floats when it 
sees 1.4 as input, see the 1-subroutine change to make-number, in 
http://www.cs.berkeley.edu/~fateman/temp/makenumber.lisp

two options are illustrated.  One will simply replace 1.4 by  7/5,  
0.125 by 1/8  etc.
The second version will replace 1.4 by 7/5  but should observe that 
0.125 is exactly 1/8 and will leave it alone.

RJF

Daniel Lakeland wrote:

>On Thu, Apr 12, 2007 at 05:06:48PM -0400, Stavros Macrakis wrote:
>  
>
>>On 4/12/07, Henning Siebel <henning.siebel at gmx.de> wrote:
>>    
>>
>>>Michel Van den Bergh <michel.vandenbergh <at> uhasselt.be> writes:
>>>http://www2.hursley.ibm.com/decimal:
>>>
>>>      
>>>
>>>>"binary floating-point arithmetic should not be used for financial,
>>>>commercial, and user-centric applications"
>>>>        
>>>>
>>Note that "scientific and mathematical" applications are not mentioned
>>here.  And indeed, binary floating-point is the standard arithmetic in those
>>domains.  It's not clear what is meant here by "user-centric"; surely not
>>simply non-system software.
>>    
>>
>
>When it comes down to it, you'll find that the median person rarely
>calculate with numbers other than for accounting purposes or the
>occasional "how many square feet of flooring do I have to buy" or
>"what's my BMI after my 3 week diet". So really "user-centric" is
>going to be close to "accounting".
>
>Many of the calculators you'll see on people's desks are the
>"+,-,*,/,=" variety.
>
>  
>
>>But your original question did set into motion an interesting discussion.  I
>>still think that the conclusion for now is very simple: set the default
>>number of digits to print as 15 (or even 14) rather than 16.
>>    
>>
>
>I vote for fpprintprec = 6. How often do you really want to see
>2.71828182845905 vs just 2.71828. For those who care it's not too hard
>to figure out how to get more. For reference, the statistical software
>"R" uses an equivalent of fpprintprec = 7 even though it uses double
>floats. An example interation in R:
>
>
>  
>
>>sqrt(2)
>>    
>>
>[1] 1.414214
>  
>
>>sqrt(2)*sqrt(2)
>>    
>>
>[1] 2
>  
>
>>sprintf("%.16f",sqrt(2)*sqrt(2))
>>    
>>
>[1] "2.0000000000000004"
>  
>
>
>(the [1] means it's a vector of 1 element)
>
>  
>