From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 6279 invoked by alias); 12 Sep 2014 23:43:04 -0000 Mailing-List: contact zsh-users-help@zsh.org; run by ezmlm Precedence: bulk X-No-Archive: yes List-Id: Zsh Users List List-Post: List-Help: X-Seq: 19079 Received: (qmail 24449 invoked from network); 12 Sep 2014 23:43:01 -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=-1.9 required=5.0 tests=BAYES_00,FREEMAIL_FROM, RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.2 Date: Sat, 13 Sep 2014 00:42:54 +0100 From: Dominik Vogt To: zsh-users@zsh.org Subject: Re: Determining the length of "long"? Message-ID: <20140912234254.GA30434@gmx.de> Reply-To: dominik.vogt@gmx.de Mail-Followup-To: zsh-users@zsh.org References: <20140911213608.GA1029@gmx.de> <140911213901.ZM21898@torch.brasslantern.com> <20140912084230.GA4226@linux.vnet.ibm.com> <140912161627.ZM23323@torch.brasslantern.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <140912161627.ZM23323@torch.brasslantern.com> User-Agent: Mutt/1.5.21 (2010-09-15) X-Provags-ID: V03:K0:Txa+lTzkkpWrl5047kENRbn8wtzBVyOwjfMr78X0/0dxDrZtfXG liz+GbAXZMSSHVUONtoBYiHVY16kFrdGJFRn7w7qAebl5XgusMIr+zKegNArxLj4EP71gDw O1RGIBvzLNEC1uMAJz96R3/WiR/BGO21fvRj6juKNWj6B6gUNAxAgK11ailBdCrsYHQvLA9 JBTUkSGA8oBXlcxp8hJTw== X-UI-Out-Filterresults: notjunk:1; On Fri, Sep 12, 2014 at 04:16:27PM -0700, Bart Schaefer wrote: > On Sep 12, 9:42am, Dominik Vogt wrote: > } > } On Thu, Sep 11, 2014 at 09:39:01PM -0700, Bart Schaefer wrote: > } > if (( ${#:-"$(( [#2] (1<<31)))"} > ${#:-"$(( [#2] (1<<63)))"} )) > } > then print "zsh integer type is 32 bits" > } > elif (( ${#:-"$(( [#2] (1<<63)))"} > ${#:-"$(( [#2] (1<<64)))"} )) > } > then print "zsh integer type is 64 bits" > } > else print "zsh integer type is more than 64 bits" > } > fi > } > } Hm, I'm not really sure that works reliably because the shift > } amount may be truncated before it is used. I.e. on s390 "1 << 32" > } and "1 << 64" and "1 << 0" are all the same. > > That probably means that zsh uses a 32 bit integer type on s390. > There is a reason the shift in my "if" above is 1<<31 not 32. To clarify, on s390 (1 << 31) has the same result as (1 << 63) *if* the integer type is long (which I doubt, zsh probably uses long long). So this is not correct > } > if (( ${#:-"$(( [#2] (1<<31)))"} > ${#:-"$(( [#2] (1<<63)))"} )) ^^^^ | this should be 32 The underlying assumption of the test that shifting an integer value to the left by its width in bits or more yields zero is wrong on some platforms. Anyway, if zsh uses long long when that's available on a 32 bit platform, the test doesn't tell me anything about long. Ciao Dominik ^_^ ^_^ -- Dominik Vogt