From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Original-To: poffice@blade.nagaokaut.ac.jp Delivered-To: poffice@blade.nagaokaut.ac.jp Received: from kankan.nagaokaut.ac.jp (kankan.nagaokaut.ac.jp [133.44.2.24]) by blade.nagaokaut.ac.jp (Postfix) with ESMTP id 43C9C17C44FB for ; Sun, 30 Oct 2011 21:40:01 +0900 (JST) Received: from funfun.nagaokaut.ac.jp (funfun.nagaokaut.ac.jp [133.44.2.201]) by kankan.nagaokaut.ac.jp (Postfix) with ESMTP id 636B4EA6324 for ; Sun, 30 Oct 2011 21:30:08 +0900 (JST) Received: from localhost (localhost.nagaokaut.ac.jp [127.0.0.1]) by funfun.nagaokaut.ac.jp (Postfix) with ESMTP id 3DFFD8FC26 for ; Sun, 30 Oct 2011 21:30:09 +0900 (JST) X-Virus-Scanned: amavisd-new at funfun.nagaokaut.ac.jp Received: from funfun.nagaokaut.ac.jp ([127.0.0.1]) by localhost (funfun.nagaokaut.ac.jp [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id NULA5ZLBZS92 for ; Sun, 30 Oct 2011 21:30:09 +0900 (JST) Received: from voscc.nagaokaut.ac.jp (voscc.nagaokaut.ac.jp [133.44.1.100]) by funfun.nagaokaut.ac.jp (Postfix) with ESMTP id 1D13F8FC22 for ; Sun, 30 Oct 2011 21:30:09 +0900 (JST) Received: from carbon.ruby-lang.org (carbon.ruby-lang.org [221.186.184.68]) by voscc.nagaokaut.ac.jp (Postfix) with ESMTP id 5F85E95241E for ; Sun, 30 Oct 2011 21:30:05 +0900 (JST) Received: from beryllium.ruby-lang.org (beryllium.ruby-lang.org [127.0.0.1]) by carbon.ruby-lang.org (Postfix) with ESMTP id 07F8C3C21EB41; Sun, 30 Oct 2011 21:30:04 +0900 (JST) Received: from fluorine.ruby-lang.org (www.rubyist.net [210.251.121.216]) by carbon.ruby-lang.org (Postfix) with ESMTP id D5FF43C21ED56 for ; Sun, 30 Oct 2011 21:29:58 +0900 (JST) Received: from ruby-lang.org (localhost [127.0.0.1]) by fluorine.ruby-lang.org (Postfix) with ESMTP id B3B723ED2F for ; Sun, 30 Oct 2011 21:29:58 +0900 (JST) Delivered-To: ruby-core@ruby-lang.org Date: Sun, 30 Oct 2011 21:29:59 +0900 Posted: Sun, 30 Oct 2011 21:29:58 +0900 From: Alexey Muranov Reply-To: ruby-core@ruby-lang.org Subject: [ruby-core:40524] [ruby-trunk - Feature #5321] Introducing Numeric#exact? and Numeric#inexact? To: ruby-core@ruby-lang.org Message-Id: References: X-ML-Name: ruby-core X-Mail-Count: 40524 X-MLServer: fml [fml 4.0.3 release (20011202/4.0.3)]; post only (only members can post) X-ML-Info: If you have a question, send e-mail with the body "help" (without quotes) to the address ruby-core-ctl@ruby-lang.org; help= X-Mailer: Redmine X-Spam-Checker-Version: SpamAssassin 3.1.7-deb3 (2006-10-05) on carbon.ruby-lang.org X-Spam-Level: X-Spam-Status: No, score=0.1 required=7.0 tests=BAYES_50,CONTENT_TYPE_PRESENT, FORGED_RCVD_HELO,X_MAILER_PRESENT autolearn=disabled version=3.1.7-deb3 X-Redmine-Issue-Author: mrkn X-Redmine-Issue-Assignee: matz X-Redmine-Issue-Id: 5321 X-Redmine-Mailinglistintegration-Message-Ids: 10014 X-Redmine-Project: ruby-trunk Auto-Submitted: auto-generated X-Redmine-Site: Ruby Issue Tracking System X-Redmine-Host: redmine.ruby-lang.org Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Precedence: bulk List-Id: ruby-core.ruby-lang.org List-Software: fml [fml 4.0.3 release (20011202/4.0.3)] List-Post: List-Owner: List-Help: List-Unsubscribe: Issue #5321 has been updated by Alexey Muranov. Charles, this is from the documentation of BigDecimal: "If a computation results in a value which is too small to be represented as a BigDecimal within the currently specified limits of precision, zero must be returned.". Thus the operations on BigDecimal are not exact. (See also BigDecimal::ROUND_MODE.) For me it is easier to think simply whether a class is *intended* to represent numbers exactly. The formal definition of exactness probably is the following: "Each operation must be carried out exactly or return NaN or nil, or return some other *exceptional* value." -Alexey. ---------------------------------------- Feature #5321: Introducing Numeric#exact? and Numeric#inexact? http://redmine.ruby-lang.org/issues/5321 Author: Kenta Murata Status: Open Priority: Normal Assignee: Yukihiro Matsumoto Category: 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. -- http://redmine.ruby-lang.org