From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on dcvr.yhbt.net X-Spam-Level: X-Spam-ASN: AS4713 221.184.0.0/13 X-Spam-Status: No, score=-3.9 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED, SPF_HELO_NONE,SPF_PASS shortcircuit=no autolearn=ham autolearn_force=no version=3.4.2 Received: from neon.ruby-lang.org (neon.ruby-lang.org [221.186.184.75]) by dcvr.yhbt.net (Postfix) with ESMTP id AED791F466 for ; Wed, 15 Jan 2020 03:03:53 +0000 (UTC) Received: from neon.ruby-lang.org (localhost [IPv6:::1]) by neon.ruby-lang.org (Postfix) with ESMTP id 3D4BA120A43; Wed, 15 Jan 2020 12:03:39 +0900 (JST) Received: from xtrwkhkc.outbound-mail.sendgrid.net (xtrwkhkc.outbound-mail.sendgrid.net [167.89.16.28]) by neon.ruby-lang.org (Postfix) with ESMTPS id 3F1C6120A40 for ; Wed, 15 Jan 2020 12:03:37 +0900 (JST) Received: by filterdrecv-p3mdw1-56c97568b5-s82th with SMTP id filterdrecv-p3mdw1-56c97568b5-s82th-20-5E1E810E-3A 2020-01-15 03:03:42.605053973 +0000 UTC m=+2514032.579752524 Received: from herokuapp.com (unknown [54.227.193.20]) by ismtpd0089p1iad2.sendgrid.net (SG) with ESMTP id oqGSlTPMTt2iy9WnozVhBQ for ; Wed, 15 Jan 2020 03:03:42.491 +0000 (UTC) Date: Wed, 15 Jan 2020 03:03:42 +0000 (UTC) From: akr@fsij.org Message-ID: References: Mime-Version: 1.0 X-Redmine-MailingListIntegration-Message-Ids: 72527 X-Redmine-Project: ruby-master X-Redmine-Issue-Id: 5321 X-Redmine-Issue-Author: mrkn X-Redmine-Issue-Assignee: matz X-Redmine-Sender: akr X-Mailer: Redmine X-Redmine-Host: bugs.ruby-lang.org X-Redmine-Site: Ruby Issue Tracking System X-Auto-Response-Suppress: All Auto-Submitted: auto-generated X-SG-EID: =?us-ascii?Q?wr6S=2F0rS9KcpExQc7ATPeOPNOIjnBAThnQXlHCXEyHAPDLPx7DjiHkDzF4DILT?= =?us-ascii?Q?bxm35QH0hty5gcKU+XdNGV6BM69=2FP256qkuHnJy?= =?us-ascii?Q?wWWcBauSqilt8FzL4JnCAQA3lv9j3s3d+7qo05n?= =?us-ascii?Q?XrLxWnogSYeBtEEUvMep7PsXwMtY2R00cHIua5c?= =?us-ascii?Q?53r37DE6x9cXDqVRTvXqAzUxlNQPyNON1Fw=3D=3D?= To: ruby-core@ruby-lang.org X-ML-Name: ruby-core X-Mail-Count: 96864 Subject: [ruby-core:96864] [Ruby master Feature#5321] Introducing Numeric#exact? and Numeric#inexact? X-BeenThere: ruby-core@ruby-lang.org X-Mailman-Version: 2.1.15 Precedence: list Reply-To: Ruby developers List-Id: Ruby developers List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: ruby-core-bounces@ruby-lang.org Sender: "ruby-core" Issue #5321 has been updated by akr (Akira Tanaka). sawa (Tsuyoshi Sawada) wrote: > akr (Akira Tanaka) wrote: > > I think associating class with exactness is wrong idea. > > ... > > I think exactness and inexactness is a property of a method, not class. > > But notice that these operations are binary operations, not unary. You cannot talk about just `Integer#+` or `Float#+`, etc. You have to think about integer + integer, float + integer, integer + float, float + float, etc. And float + integer and integer + float are the same as float + float with respect to exactness. The reason should be attributed to some notion of hierarchy of exactness between the classes; float is less exact than integer, and the exactness of + would be the minimum exactness of the operands on both sides. I see. I wrongly assumed integer + integer for Integer#+. > Hence, at least, the classes should also need to carry some kind of notion of exactness. Do you have good definition of exactness of numeric classes? ---------------------------------------- Feature #5321: Introducing Numeric#exact? and Numeric#inexact? https://bugs.ruby-lang.org/issues/5321#change-83877 * Author: mrkn (Kenta Murata) * Status: Assigned * Priority: Normal * Assignee: matz (Yukihiro Matsumoto) * Target version: ---------------------------------------- Ruby has several numeric classes such as Integer. These classes are classified whether their instances represent numbers exactly. According to this, Integer and Rational are exact, and Float and BigDecimal are inexact because they're always including error. The exactness of a Complex depends on its real and imaginary parts. Now, Ruby's numeric classes doesn't provide predicators to investigate the exactness of their instances. So, if we want to examine whether a number is exactly zero, we must investigate the class of the number. I want simple way to examine the number exactness. I propose to introduce Numeric#exact? and/or Numeric#inexact? for resolving this inconvenience. ---Files-------------------------------- numeric-exact-5321.patch (7.33 KB) -- https://bugs.ruby-lang.org/