From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 14148 invoked by alias); 3 May 2015 19:49:35 -0000 Mailing-List: contact zsh-workers-help@zsh.org; run by ezmlm Precedence: bulk X-No-Archive: yes List-Id: Zsh Workers List List-Post: List-Help: X-Seq: 35019 Received: (qmail 11371 invoked from network); 3 May 2015 19:49:32 -0000 X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on f.primenet.com.au X-Spam-Level: X-Spam-Status: No, score=-2.7 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,HTML_MESSAGE,RCVD_IN_DNSWL_LOW autolearn=ham version=3.3.2 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:from:date:message-id:subject:to:content-type; bh=k/qDlfVnzqwivPwrJhqitWZzKfZ75tF0pfKgc9Yj754=; b=RveP2KlIQ7tHgQk8j0HWMCvdEYpBARLTJkBauygQ6PuYeuwj/tq9QTtkohd1Cjqx1S TdQyeuRaS+9K8adhjG3+ZN2t9nIcF47xVgjk7bqeqzgcKBdka4G3VeEXlTxaQkMfg3QE vZMEk568JQb6T9CFtAPL6yZ4tpIjpcnNPdE7OFAvslEjpEhbEV1EoM13eCINeIr9XsZu JIJwLqcf/xkswyXKltfht/2xpqUs9aSpX5ZtE0EW9tpGlsf0JrhQ0UIl1jvGAEtFYGj0 Udr3RbZzM5jHh1mgbaS8eJt9uQ6FFDYi+TP68M1wBvf5bCUSZvQtSExzNQNAN9Og+TkS gzCA== X-Received: by 10.194.204.230 with SMTP id lb6mr35133562wjc.63.1430680869922; Sun, 03 May 2015 12:21:09 -0700 (PDT) MIME-Version: 1.0 From: David Hughes Date: Sun, 03 May 2015 19:21:09 +0000 Message-ID: Subject: 'typeset -F' behaves unexpectedly for "-F 1" and "-F 0" To: zsh-workers@zsh.org Content-Type: multipart/alternative; boundary=047d7b8738a209ef1805153259b8 --047d7b8738a209ef1805153259b8 Content-Type: text/plain; charset=ISO-8859-1 If I run "typeset -F 1 pi=3.14159", I receive a warning of an invalid base, and the parameter is not initialised. However, the parameter appears to be created, and thereafter has the expected rounding attribute: $ typeset -F 1 pi=3.14159 typeset: invalid base (must be 2 to 36 inclusive): 1 $ echo $pi 0.0 $ pi=2.71828 $ echo $pi 2.7 With "-F 0", the warning is also shown, and the parameter is also configured as a floating point, but when I expand the parameter its precision is set to the default 10 decimal places: $ unset pi $ typeset -F 0 pi=3.14159 typeset: invalid base (must be 2 to 36 inclusive): 0 $ echo $pi 0.0000000000 $ pi=2 $ echo $pi 2.0000000000 The behaviour I expect is that 'pi' should be rounded to one decimal place with "-F 1", and to the nearest integer with "-F 0". As a fabricated example: $ typeset -F 1 pi=3.14159 $ echo $pi 3.1 $ typeset -F 0 e=2.71828 $ echo $e 3 For values of "-F" greater than one, zsh behaves as I expect: no warnings are issued, and the expanded value is rounded to the specified number of places: $ typeset -F 3 pi=3.14159 $ echo $pi 3.142 I have replicated this in zsh 5.0.5, and I do not see any related bug when searching http://sourceforge.net/p/zsh/bugs/ for "typeset" or "float", so I guess this issue is still extant in the dev version. I didn't have enough C skill to understand the relevant parameter code and structs from bin_typeset() down to typeset_setbase() within an hour, but please let me know if I can provide more information at a simpler level. --047d7b8738a209ef1805153259b8--