From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 15528 invoked from network); 9 Jan 2002 13:56:33 -0000 Received: from sunsite.dk (130.225.247.90) by ns1.primenet.com.au with SMTP; 9 Jan 2002 13:56:33 -0000 Received: (qmail 18153 invoked by alias); 9 Jan 2002 13:56:26 -0000 Mailing-List: contact zsh-workers-help@sunsite.dk; run by ezmlm Precedence: bulk X-No-Archive: yes X-Seq: 16423 Received: (qmail 18139 invoked from network); 9 Jan 2002 13:56:25 -0000 To: zsh-workers@sunsite.dk (Zsh hackers list) Subject: PATCH: floating point output Date: Wed, 09 Jan 2002 13:55:52 +0000 Message-ID: <27391.1010584552@csr.com> From: Peter Stephenson I just noticed: (( A = 1.2e12 )) print $A prints `1200000000000', with no decimal point. Hence if A is a scalar the number is treated in future as an integer. This causes problems for example if you try to square it: try entering `1.2e12' then `$1 ** 2' in zcalc. The math code correctly returns a floating point number, but convfloat doesn't check there is a `.' or `e' in the result. This might simply be an effect of the Solaris sprintf() implementation. The same occurs with e.g. 1.0000, although that's usually less of a problem. This is the simplest patch I can think of. I haven't added any extra digits because the number of digits has already been worked out, just the `.'. I don't think this should cause problems. Index: Src/params.c =================================================================== RCS file: /cvsroot/zsh/zsh/Src/params.c,v retrieving revision 1.58 diff -u -r1.58 params.c --- Src/params.c 2001/12/18 14:51:31 1.58 +++ Src/params.c 2002/01/09 13:45:09 @@ -3357,6 +3357,8 @@ } else { VARARR(char, buf, 512 + digits); sprintf(buf, fmt, digits, dval); + if (!strchr(buf, 'e') && !strchr(buf, '.')) + strcat(buf, "."); return dupstring(buf); } } -- Peter Stephenson Software Engineer CSR Ltd., Science Park, Milton Road, Cambridge, CB4 0WH, UK Tel: +44 (0)1223 392070 ********************************************************************** The information transmitted is intended only for the person or entity to which it is addressed and may contain confidential and/or privileged material. Any review, retransmission, dissemination or other use of, or taking of any action in reliance upon, this information by persons or entities other than the intended recipient is prohibited. If you received this in error, please contact the sender and delete the material from any computer. **********************************************************************