ruby-core@ruby-lang.org archive (unofficial mirror)
 help / color / mirror / Atom feed
From: Alexey Muranov <muranov@math.univ-toulouse.fr>
To: ruby-core@ruby-lang.org
Subject: [ruby-core:40570] [ruby-trunk - Feature #5321] Introducing Numeric#exact? and Numeric#inexact?
Date: Tue, 1 Nov 2011 00:32:19 +0900	[thread overview]
Message-ID: <redmine.journal-21719.20111101003218@ruby-lang.org> (raw)
In-Reply-To: redmine.issue-5321.20110914132016@ruby-lang.org


Issue #5321 has been updated by Alexey Muranov.


Kenta Murata wrote:
> Alexey Muranov wrote:
> > In my opinion, checking `x.class.exact?` would be good enough.
> 
> I don't think so for two reason.
> First, I think the form of "x.class.exact?' isn't ruby way, and too long than "x.exact?".
> Second, it limits the exactness property for class.
> 
> Numeric classes including both exact and inexact instances should be allowed, I think.

I am not against Numeric classes including both exact and inexact instances :).  I just doubt it is a good idea to define this in the Numeric class itself, it would looks too heavy for me. (Being able to check whether a given integer is exact? does not look valuable to me.)  It sounds like what  Yusuke Endoh  said about exactness in Scheme (which i do not know).  This would probably mean that you need to set the exactness flag for the first time when you read a value from the input, or it should be set to inexact by default (or, even worse, to exact or inexact depending on the default for the class), which will make you think if your output is inexact because an inexact operation was carried out, or because the exact flag was not set correctly on the first input.  I see benefit in being able to mix exact and inexact values, but it can be done even if exactness is defined on the (sub)class level.  Keeping track of what influences exactness of your value seems easier if you kno
 w that it is a class property.  I think this is all i had in mind.
----------------------------------------
Feature #5321: Introducing Numeric#exact? and Numeric#inexact?
http://redmine.ruby-lang.org/issues/5321

Author: Kenta Murata
Status: Assigned
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

  parent reply	other threads:[~2011-10-31 15:42 UTC|newest]

Thread overview: 26+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-09-14  4:20 [ruby-core:39539] [Ruby 1.9 - Feature #5321][Open] Introducing Numeric#exact? and Numeric#inexact? Kenta Murata
2011-10-29 22:09 ` [ruby-core:40514] [ruby-trunk - Feature #5321] " Alexey Muranov
2011-10-29 23:57 ` [ruby-core:40519] " Charles Nutter
2011-10-30 12:29 ` [ruby-core:40524] " Alexey Muranov
2011-10-31 11:04   ` [ruby-core:40553] " Alex Young
2011-10-31 12:13 ` [ruby-core:40555] [ruby-trunk - Feature #5321][Assigned] " Yusuke Endoh
2011-10-31 12:55 ` [ruby-core:40556] [ruby-trunk - Feature #5321] " Yusuke Endoh
2011-10-31 13:21 ` [ruby-core:40557] " Alexey Muranov
2011-10-31 13:32 ` [ruby-core:40558] " Kenta Murata
2011-10-31 13:54 ` [ruby-core:40559] " tadayoshi funaba
2011-10-31 14:34   ` [ruby-core:40565] " Yusuke Endoh
2011-10-31 13:55 ` [ruby-core:40560] " Kenta Murata
2011-10-31 14:24   ` [ruby-core:40563] " Yusuke Endoh
2011-10-31 14:13 ` [ruby-core:40561] " Alexey Muranov
2011-10-31 14:54 ` [ruby-core:40566] " Kenta Murata
2011-10-31 14:59 ` [ruby-core:40567] " tadayoshi funaba
2011-10-31 15:32 ` Alexey Muranov [this message]
2011-11-01 12:14 ` [ruby-core:40622] [ruby-trunk - Feature #5321][Assigned] " Masaya Tarui
2012-11-20 11:55 ` [ruby-core:49681] [ruby-trunk - Feature #5321] " mame (Yusuke Endoh)
2019-08-01  1:02 ` [ruby-core:94087] [Ruby master Feature#5321] " merch-redmine
2020-01-04  6:27 ` [ruby-core:96652] " wishdev
2020-01-15  2:23 ` [ruby-core:96861] " akr
2020-01-15  2:43 ` [ruby-core:96863] " sawadatsuyoshi
2020-01-15  3:03 ` [ruby-core:96864] " akr
2020-01-15  6:19 ` [ruby-core:96868] " sawadatsuyoshi
2020-01-16  8:04 ` [ruby-core:96899] " matz

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-list from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.ruby-lang.org/en/community/mailing-lists/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=redmine.journal-21719.20111101003218@ruby-lang.org \
    --to=ruby-core@ruby-lang.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).