From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on inbox.vuxu.org X-Spam-Level: X-Spam-Status: No, score=-3.3 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, MAILING_LIST_MULTI,NICE_REPLY_A,RCVD_IN_DNSWL_MED,UNPARSEABLE_RELAY autolearn=ham autolearn_force=no version=3.4.4 Received: (qmail 31054 invoked from network); 26 Mar 2021 14:37:02 -0000 Received: from zero.zsh.org (2a02:898:31:0:48:4558:7a:7368) by inbox.vuxu.org with ESMTPUTF8; 26 Mar 2021 14:37:02 -0000 ARC-Seal: i=1; cv=none; a=rsa-sha256; d=zsh.org; s=rsa-20200801; t=1616769422; b=aSte7ssAk2Davuxh7bY1tdlLOJqbEq182ul/g6qJozqDmPaYHlJmQbHtxMnPutanJjQHy9C9a2 jJSqfYBnwaCh4El9POlHFuZguv1LT/vu39Z3AB7D7J/GtQaJp+CshH+auTmq8ujRu8yZH85PDI 3TvCuNPhc1iiamCjYOT18A9KyL+zYldXD7ROmDpE9LOwEzu9wQhgeGZIeM6Fg1n4C5TPJjSu8N qE43C/CK5Xnar8w9dW0r0Cf7Vo/Ax4GwSB5EsSSa+4xJvv4pd9Ed6qots4fkPittVhapUPHjc5 jPxrWrZkcRbVWlHbPv4Iqo2HW9Fr9NFe+0XaxSm2lyLRgA==; ARC-Authentication-Results: i=1; zsh.org; iprev=pass (mta02.eastlink.ca) smtp.remote-ip=24.224.136.13; dmarc=none header.from=eastlink.ca; arc=none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed; d=zsh.org; s=rsa-20200801; t=1616769422; bh=B32y9C4jy2f7UOYJzPUjG6OoddbRVjrZ75/SgrHrpnA=; h=List-Archive:List-Owner:List-Post:List-Unsubscribe:List-Subscribe:List-Help: List-Id:Sender:Content-Transfer-Encoding:Content-Type:In-Reply-To: MIME-Version:Date:Message-ID:From:References:To:Subject:DKIM-Signature; b=w5wYP2hhnXEXwh5xjIKRrRY8gkA1sAYKAXStcmKKL8NsMeaMKlZKwSOFEdRGBGybzAI68hO/2E TW37JzBZ/jzyH2z7n6O8c18i3rfQC3RZKdI6gd2mdgTKT3D/WqTuaXXUVZDtM71h7uUxSJ5Jga 6J1cdxizNU3Rf+Z0rz+kBrYEc3MzAyyTX/teFwPFXAmHIXhLUEPNtOXJz0zavbtEEq5XgWo6JS uq1c5OOmbTwYh2/wiZhEqZ2twMg2mL2Y+GbNl1bv234tj5zfj02caxHChdVFZJEWuctVWRyV6w 88f/Pmp6LfEl/pTRIJWMNhDjLzTJBpUDl0HF/W49pWvt2w==; DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=zsh.org; s=rsa-20200801; h=List-Archive:List-Owner:List-Post:List-Unsubscribe: List-Subscribe:List-Help:List-Id:Sender:Content-transfer-encoding: Content-type:In-reply-to:MIME-version:Date:Message-id:From:References:To: Subject:Reply-To:Cc:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID; bh=a+xoqDoXFWR1vSmlk9pibEoE1VubVsDyGgfb3V6mXEs=; b=AwKjVCMuDgmGGCxUb2VuBosrkp HNTewAvpMSU08pJt1b/Ome/fHRDD61jt1VNhfk1nGTykirj1Jtl23eHPhiBGmUrUPZzYxWxKdKP+M vdvKy5CvHihtbX0YOejR/SOa7rFAhfLvZ62B62ZYkkEkyD7aihpUqT3f2thjfL/IYA124jqaGBFaN 783fypfFFQpS06JV3mGH8gGPLMWXywed5BN0233SSHbfYM0f8TfS7T13l0gE5D70S72o6YbaaQt+6 VBmMXArMTZKWlZ02Q9fktGB/TJ3dDLZ2atzSe6M1SWVtcAnujD5b4YBbZKu1VxPMBGZe1WFCsBQwW +nWeS8Sg==; Received: from authenticated user by zero.zsh.org with local id 1lPna3-000Iuy-Pl; Fri, 26 Mar 2021 14:36:55 +0000 Authentication-Results: zsh.org; iprev=pass (mta02.eastlink.ca) smtp.remote-ip=24.224.136.13; dmarc=none header.from=eastlink.ca; arc=none Received: from mta02.eastlink.ca ([24.224.136.13]:32817) by zero.zsh.org with esmtps (TLS1.2:ECDHE-RSA-AES128-GCM-SHA256:128) id 1lPnZX-000IYB-LU; Fri, 26 Mar 2021 14:36:24 +0000 Received: from csp01.eastlink.ca ([71.7.199.166]) by mta02.eastlink.ca (Oracle Communications Messaging Server 8.0.2.2.20180531 64bit (built May 31 2018)) with ESMTPS id <0QQK001R3UX1CFP0@mta02.eastlink.ca> for zsh-users@zsh.org; Fri, 26 Mar 2021 11:36:21 -0300 (ADT) Received: from [192.168.0.2] ([24.207.90.194]) by Eastlink with ESMTP id PnZVlDZyLxMqjPnZVlaZ0P; Fri, 26 Mar 2021 11:36:21 -0300 X-Authority-Analysis: v=2.4 cv=F5mSyotN c=1 sm=1 tr=0 ts=605df165 a=zv49KfEsxEDzuN5AGO7r0Q==:117 a=zv49KfEsxEDzuN5AGO7r0Q==:17 a=IkcTkHD0fZMA:10 a=yPCof4ZbAAAA:8 a=Z0U688fFtegO9Oul8hoA:9 a=QEXdDO2ut3YA:10 a=tkSBOkgIhzoA:10 a=RBBcRewTFc8P4JkPnay6:22 X-Vade-Cause: gggruggvucftvghtrhhoucdtuddrgeduledrudehvddgieekucetufdoteggodetrfdotffvucfrrhhofhhilhgvmecugfetuffvnffkpffmpdfqfgfvnecuuegrihhlohhuthemuceftddtnecunecujfgurhepuffvfhfhkffffgggjggtgfesthekredttdefjeenucfhrhhomheptfgrhicutehnughrvgifshcuoehrrgihrghnughrvgifshesvggrshhtlhhinhhkrdgtrgeqnecuggftrfgrthhtvghrnhepudffhfffvdekgfejfeeuteffveejgfejtdfhvddtjeevvdfhtdetudegkeffvdfhnecuffhomhgrihhnpehorhgrtghlvgdrtghomhenucfkphepvdegrddvtdejrdeltddrudelgeenucevlhhushhtvghrufhiiigvpedtnecurfgrrhgrmhepihhnvghtpedvgedrvddtjedrledtrdduleegpdhhvghloheplgduledvrdduieekrddtrddvngdpmhgrihhlfhhrohhmpehrrgihrghnughrvgifshesvggrshhtlhhinhhkrdgtrgdprhgtphhtthhopeiishhhqdhushgvrhhsseiishhhrdhorhhgpdhgvghtqdgkihhprfgrshhsfigupehtrhhuvg X-Vade-Score: 0 X-Vade-State: 0 X-EL-IP-NOAUTH: 24.207.90.194 Subject: Re: arithmetic anomaly To: zsh-users@zsh.org References: <0227b30d-4f09-2c8b-1248-557859d875ce@eastlink.ca> <91303-1616717760.288585@Iyj2.F9RA.VD0P> From: Ray Andrews Message-id: <6d70bc8d-73d3-7866-6485-ee89dafdebc9@eastlink.ca> Date: Fri, 26 Mar 2021 07:36:21 -0700 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.8.0 MIME-version: 1.0 In-reply-to: Content-type: text/plain; charset=utf-8; format=flowed Content-transfer-encoding: 8bit Content-language: en-US X-Seq: 26609 Archived-At: X-Loop: zsh-users@zsh.org Errors-To: zsh-users-owner@zsh.org Precedence: list Precedence: bulk Sender: zsh-users-request@zsh.org X-no-archive: yes List-Id: List-Help: List-Subscribe: List-Unsubscribe: List-Post: List-Owner: List-Archive: Archived-At: On 2021-03-26 3:35 a.m., Roman Perepelitsa wrote: > > Maybe this will help: > https://docs.oracle.com/cd/E19957-01/806-3568/ncg_goldberg.html > Good to know! Seriously, I've often wondered what really goes on in a calculator. Ok, for now I know that zsh and probably everybody else will compute endless reams of garbage if you let it.  Here's my algorithm with the outer 'for' loop increasing exponentially: Ray's  Algorithm fractional: Level: 1: win: 1 / 1 Level: 10: win: 6513215599 / 10000000000 Level: 100: win: 6339676587267708385630188881009247729557115329795338127068495312693456362833186743509112446 7602830066897486524892436064552875964380756727929631216242621046676674030227216977589219271 483398068889452544 / 9999999999999999697331222125103616594745032754550236264824175095034684843555407553419633840 4706251868027512415973882408182135734368278484639385041047239877871023591066789981811181813 306167128854888448 Level: 1000: win: inf / inf Level: 10000: win: inf / inf Level: 100000: win: inf / inf Level: 1000000: win: inf / inf .... I'm asking why the 'Level: 100' result isn't just aborted after 15 digits given that all the rest is garbage? > > Understanding how floating point numbers work is very useful. It's > virtually mandatory when writing numerical computation code. None of > this is specific to zsh. Amen!  Seriously, I had no idea this sort of thing was permitted. Thanks Roman.  For now I'll use ' %d' for output and at least I'll know when things turn to mud, there must be limits to precision and there must be overflow at some point.  (But of course we hafta use floats if there's a division anywhere, just don't use them for display.)