Hi,

On Mon, Sep 12, 2011 at 7:30 PM, Kenta Murata <muraken / gmail.com> wrote:
> =A0I believe you are misreading of the topic.

There is some inconsistency between your proposal and what has been impleme=
nted:

# integral.rb
class Numberish
  def initialize(value)
    @value =3D value
  end

  def to_int
    @value
  end
end

n =3D Numberish.new 5

p 10 & n

sasha:rubyspec brian$ ruby1.8.7 -v integral.rb
ruby 1.8.7 (2011-02-18 patchlevel 334) [i686-darwin10.8.0]
0
sasha:rubyspec brian$ ruby1.9.2 -v integral.rb
ruby 1.9.2p290 (2011-07-09 revision 32553) [x86_64-darwin10.8.0]
0
sasha:rubyspec brian$ ruby1.9 -v integral.rb
ruby 1.9.4dev (2011-09-12 trunk 33259) [x86_64-darwin10.8.0]
integral.rb:13:in `&': can't convert Numberish into Integer for
bitwise arithmetic (TypeError)
	from integral.rb:13:in `<main>'

>
> On Tuesday, September 13, 2011 at 11:03 , brian ford wrote:
>> Any object should be allowed to participate in integral operations
>> based on the object's implementing #to_int.
>
> My proposal doesn't disturb that, and I don't want to interfere that.
>
> I want to allow anyone to create original "integral" numbers which can be=
have alike Fixnum and Bignum.
> Unfortunately, to_int is currently used for converting to an Integer from=
 a non-integral, inexact number like a Float.

A Float value is a machine approximation of a mathematical real
number. A BigDecimal is an exact representation of a real number. The
mathematical real numbers embed the integers. A real number can be
viewed on a 2 dimensional plane much like a complex number. A real
number of form a.b can be location on this 2d plane by indexing a on
the x-axis and b on the y-axis, where the x- and y-axis are integral
values. Any real number can thus represent an integral value as the
projection of the real value onto the x-axis. A variety of ways of
representing real values actually exist. There are ceil, floor,
truncate, round.

It is untrue that Float numbers cannot be consistently represented as
integral values. It is merely up to the language to define them as
such. Ruby already takes liberties with defining mathematical
operations (see http://redmine.ruby-lang.org/issues/3289).

To remove #to_int from Float and BigDecimal and partially from
Rational and Complex introduces typing concepts where none are needed,
breaks consistent polymorphism, and breaks compatibility with 1.8 and
prior 1.9.

Further, it makes no sense to omit Float from participating when you
suggest it would be fine to allow some other object, which has no
requirement that it represent some "exact" integral value, to
participate.

Brian

>
> --
> Kenta Murata
> Sent with Sparrow (http://www.sparrowmailapp.com)
>
>
>
>