From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: John Yates Newsgroups: gmane.emacs.help Subject: Re: What is 0.01 here not 0.01 here 0.009999999999999? Date: Fri, 2 Apr 2021 16:46:26 -0400 Message-ID: References: Mime-Version: 1.0 Content-Type: text/plain; charset="UTF-8" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="4490"; mail-complaints-to="usenet@ciao.gmane.io" To: Stefan Monnier , Help Gnu Emacs mailing list Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane-mx.org@gnu.org Fri Apr 02 22:48:39 2021 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1lSQid-00014E-7B for geh-help-gnu-emacs@m.gmane-mx.org; Fri, 02 Apr 2021 22:48:39 +0200 Original-Received: from localhost ([::1]:38866 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lSQic-0004Md-7E for geh-help-gnu-emacs@m.gmane-mx.org; Fri, 02 Apr 2021 16:48:38 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:54582) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lSQgj-0004FI-Nz for help-gnu-emacs@gnu.org; Fri, 02 Apr 2021 16:46:43 -0400 Original-Received: from mail-lf1-f45.google.com ([209.85.167.45]:45962) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1lSQgh-0006ZM-Se for help-gnu-emacs@gnu.org; Fri, 02 Apr 2021 16:46:41 -0400 Original-Received: by mail-lf1-f45.google.com with SMTP id g8so9023970lfv.12 for ; Fri, 02 Apr 2021 13:46:38 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to; bh=FVve/ZUDUQz64qPFWgPnW/+g2nNqi5of7DVeq+uRHaE=; b=VKZCw0Z6onXws1mxvFnv2/W/MDdXlQpZLg3tOl77sPPyTAJu0fX8tS6WmPYhr6Mccj S5KcdMIalMnz5+qXkE6E+luySZ3EBQsplbVqb/l7D67bbXNKYn71Xy30g1rnvpcWPYQo nRh/eUCi6PytfFe3S8g42wgngmaH2BTPLQpKR1bcWYAuM7N5Mtske4AigWrPJGADUcvH XBYw78HS5+2+aU8A1AHTb29Fhb5CWKjq5v7Lxk8er3+o/nZgBj0vlfuP8vTL1DeWkMEl VcJx45s6JhgSR4yKhvGr+ABkw3HycfWUMA2iWAuTTUMUA0r4x2ln472478OTt35R90IT 1gJg== X-Gm-Message-State: AOAM533sDYiA+lx/GbrM+OuXgwf6d9oe7vDWnFNtqVXEFdlmUMhtB3Dy N2psYJC/c0icP4pCmLSLrwe5l5TnVsGW8jfL+DZuqRRaH//2Fw== X-Google-Smtp-Source: ABdhPJxfEFagRofzrjLYa0bn6vXzsPr17DVKYoIQguh7Vq1cjRgK5yJbrMEppGWvVE9yAFOiSyFE/ORIP06i9f4/lEg= X-Received: by 2002:ac2:5382:: with SMTP id g2mr9857693lfh.60.1617396397491; Fri, 02 Apr 2021 13:46:37 -0700 (PDT) In-Reply-To: Received-SPF: pass client-ip=209.85.167.45; envelope-from=john.yates.sheets@gmail.com; helo=mail-lf1-f45.google.com X-Spam_score_int: -10 X-Spam_score: -1.1 X-Spam_bar: - X-Spam_report: (-1.1 / 5.0 requ) BAYES_00=-1.9, FREEMAIL_FORGED_FROMDOMAIN=0.249, FREEMAIL_FROM=0.001, HEADER_FROM_DIFFERENT_DOMAINS=0.25, HTML_MESSAGE=0.001, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, URI_DOTEDU=0.275 autolearn=no autolearn_force=no X-Spam_action: no action X-Content-Filtered-By: Mailman/MimeDel 2.1.23 X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: "help-gnu-emacs" Xref: news.gmane.io gmane.emacs.help:128822 Archived-At: On Fri, Apr 2, 2021 at 1:07 PM Jean Louis wrote: > Thank you. I did browse it, did not yet understand it. And so, having made no progress towards understanding computer-based floating point arithmetic, you press on arguing from a position of ignorance. Put most simply, on a machine in which floating point numbers encode the significand (sometimes erroneously termed the 'mantissa') using a binary representation, there is no way to encode, and hence express, a fraction whose divisor is not a power of 2. So you can encode precisely 1/2, 1/4, 1/128, etc. But you will never have a precise encoding of 1/3, 1/5, 1/10, etc. Much effort has gone into optimizing "round tripping", the conversion of decimal numbers into the nearest floating point number and getting it back out again. But you are asking for more. You want arithmetic on imprecise representations of your perfect decimal numbers to deliver precisely the same result as your mental model. That is never going to happen. I am not going to try to explain normalization, rounding, rounding modes, etc. Suffice it to say that this is the realm of numerical analysis, a rich field that traces its roots straight back to Alen Turing. In closing, let me recommend David Goldberg's classic 'What every computer scientist should know about floating-poing arithmetic '. /john