[#64517] Fw: Re: Ruby and Rails to become Apache Incubator Project — Tetsuya Kitahata <kitahata@99.alumni.u-tokyo.ac.jp>

What do you think? >> Ruby developers

13 messages 2014/08/23

[#64615] [ruby-trunk - Feature #10181] [Open] New method File.openat() — oss-ruby-lang@...

Issue #10181 has been reported by Technorama Ltd..

10 messages 2014/08/28
[#64616] Re: [ruby-trunk - Feature #10181] [Open] New method File.openat() — Eric Wong <normalperson@...> 2014/08/28

I like this feature.

[#64671] Fwd: [ruby-changes:35240] normal:r47322 (trunk): symbol.c (rb_sym2id): do not return garbage object — SASADA Koichi <ko1@...>

Why this fix solve your problem?

9 messages 2014/08/30
[#64672] Re: Fwd: [ruby-changes:35240] normal:r47322 (trunk): symbol.c (rb_sym2id): do not return garbage object — SASADA Koichi <ko1@...> 2014/08/30

(2014/08/30 8:50), SASADA Koichi wrote:

[ruby-core:64678] [ruby-trunk - Feature #7517] Fixnum::MIN,MAX

From: cremno@...
Date: 2014-08-30 22:30:11 UTC
List: ruby-core #64678
Issue #7517 has been updated by cremno phobia.


Even if the use-cases aren't really convincing, I think the informational purpose alone is a good enough argument to add it. If you search for “ruby fixnum max” or something similar, you'll find the interest is there, but the solution(s) usually only work in CRuby and are not as easy to understand as the proposed constants.

~~~ diff
diff --git a/numeric.c b/numeric.c
index 1e971f4..b57c686 100644
--- a/numeric.c
+++ b/numeric.c
@@ -4062,6 +4062,15 @@ Init_Numeric(void)

     rb_cFixnum = rb_define_class("Fixnum", rb_cInteger);

+    /*
+     *	The minimum value of a Fixnum.
+     */
+    rb_define_const(rb_cFixnum, "MIN", LONG2FIX(FIXNUM_MIN));
+    /*
+     *	The maximum value of a Fixnum.
+     */
+    rb_define_const(rb_cFixnum, "MAX", LONG2FIX(FIXNUM_MAX));
+
     rb_define_method(rb_cFixnum, "to_s", fix_to_s, -1);
     rb_define_alias(rb_cFixnum, "inspect", "to_s");

diff --git a/test/ruby/test_fixnum.rb b/test/ruby/test_fixnum.rb
index 8b2cf2e..8c896ec 100644
--- a/test/ruby/test_fixnum.rb
+++ b/test/ruby/test_fixnum.rb
@@ -312,4 +312,20 @@ class TestFixnum < Test::Unit::TestCase
     assert_equal(1, 5.remainder(4))
     assert_predicate(4.remainder(Float::NAN), :nan?)
   end
+
+  def test_min
+    assert_kind_of(Fixnum, Fixnum::MIN)
+    assert_kind_of(Bignum, Fixnum::MIN - 1)
+    if RUBY_ENGINE == 'ruby'
+      assert_equal(-2 ** (1.size * 8 - 2), Fixnum::MIN)
+    end
+  end
+
+  def test_max
+    assert_kind_of(Fixnum, Fixnum::MAX)
+    assert_kind_of(Bignum, Fixnum::MAX + 1)
+    if RUBY_ENGINE == 'ruby'
+      assert_equal(2 ** (1.size * 8 - 2) - 1, Fixnum::MAX)
+    end
+  end
 end
~~~

----------------------------------------
Feature #7517: Fixnum::MIN,MAX
https://bugs.ruby-lang.org/issues/7517#change-48573

* Author: Yukihiro Matsumoto
* Status: Assigned
* Priority: Normal
* Assignee: Yukihiro Matsumoto
* Category: core
* Target version: next minor
----------------------------------------
Maximum (or minimum) number of fixnum can not be get in portable fashion, so I propose Fixnum::MAX and Fixnum::MIN just like Float::MAX and Float::MIN.

Matz



-- 
https://bugs.ruby-lang.org/

In This Thread