Issue #7517 has been reported by matz (Yukihiro Matsumoto). ---------------------------------------- Feature #7517: Fixnum::MIN,MAX https://bugs.ruby-lang.org/issues/7517 Author: matz (Yukihiro Matsumoto) Status: Open Priority: Normal Assignee: 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
on 2012-12-05 14:32
on 2012-12-05 14:50
Issue #7517 has been updated by Eregon (Benoit Daloze). I agree, I was thinking about it the other day remembering all the custom test code to find these and comparing with Float constants. ---------------------------------------- Feature #7517: Fixnum::MIN,MAX https://bugs.ruby-lang.org/issues/7517#change-34416 Author: matz (Yukihiro Matsumoto) Status: Open Priority: Normal Assignee: 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
on 2012-12-05 15:14
Issue #7517 has been updated by mrkn (Kenta Murata). +1 ---------------------------------------- Feature #7517: Fixnum::MIN,MAX https://bugs.ruby-lang.org/issues/7517#change-34417 Author: matz (Yukihiro Matsumoto) Status: Open Priority: Normal Assignee: 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
on 2012-12-05 19:25
Issue #7517 has been updated by shyouhei (Shyouhei Urabe). I'm not against these constant. Just wanted to note that (for instance) max Fixnum can portally be obtained via: 1 << (1.size * 8 - 2) - 1 ---------------------------------------- Feature #7517: Fixnum::MIN,MAX https://bugs.ruby-lang.org/issues/7517#change-34434 Author: matz (Yukihiro Matsumoto) Status: Open Priority: Normal Assignee: 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
on 2012-12-05 19:39
On Wed, Dec 5, 2012 at 12:24 PM, shyouhei (Shyouhei Urabe) <shyouhei@ruby-lang.org> wrote: > I'm not against these constant. Just wanted to note that (for instance) max Fixnum can portally be obtained via: > > 1 << (1.size * 8 - 2) - 1 Not on JRuby. JRuby's Fixnum is always a full signed 64-bit integer. system ~/projects/jruby $ jirb irb(main):001:0> 1.size => 8 irb(main):002:0> big = java.lang.Long::MAX_VALUE => 9223372036854775807 irb(main):003:0> big.to_s(2) => "111111111111111111111111111111111111111111111111111111111111111" irb(main):004:0> big.class => Fixnum irb(main):005:0> small = java.lang.Long::MIN_VALUE => -9223372036854775808 irb(main):006:0> small.to_s(2) => "-1000000000000000000000000000000000000000000000000000000000000000" irb(main):007:0> small.class => Fixnum I support adding MIN and MAX to Fixnum.
on 2012-12-05 23:11
On 12/05/2012 10:38 AM, Charles Oliver Nutter wrote: > On Wed, Dec 5, 2012 at 12:24 PM, shyouhei (Shyouhei Urabe) > <shyouhei@ruby-lang.org> wrote: >> I'm not against these constant. Just wanted to note that (for instance) max Fixnum can portally be obtained via: >> >> 1 << (1.size * 8 - 2) - 1 > > Not on JRuby. JRuby's Fixnum is always a full signed 64-bit integer. Oh, good to know that. So you always use boxed types and unboxing is left to the VM.
on 2012-12-06 06:24
On Wed, Dec 5, 2012 at 4:11 PM, Urabe Shyouhei <shyouhei@ruby-lang.org>
wrote:
> Oh, good to know that. So you always use boxed types and unboxing is left to
the VM.
Correct.
on 2012-12-06 15:29
Issue #7517 has been updated by matz (Yukihiro Matsumoto). Assignee set to mame (Yusuke Endoh) Target version changed from next minor to 2.0.0 Endo san, since it's a small and useful change, can I merge this for 2.0 even after spec freeze? Of course, you can reject as a release manager. In that case, file this proposal as "next minor" again. Matz. ---------------------------------------- Feature #7517: Fixnum::MIN,MAX https://bugs.ruby-lang.org/issues/7517#change-34479 Author: matz (Yukihiro Matsumoto) Status: Open Priority: Normal Assignee: mame (Yusuke Endoh) Category: core Target version: 2.0.0 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
on 2012-12-06 16:00
Issue #7517 has been updated by mame (Yusuke Endoh). Status changed from Open to Assigned Assignee changed from mame (Yusuke Endoh) to matz (Yukihiro Matsumoto) matz (Yukihiro Matsumoto) wrote: > Endo san, since it's a small and useful change, can I merge this for 2.0 even after spec freeze? > Of course, you can reject as a release manager. In that case, file this proposal as "next minor" again. As a release manager, okay. Because matz accepted the proposal :-) Personally, however, I'm not sure when it is useful. I guess that you want to avoid an boxed integer for saving memory on an embedded system, right? But I don't know how it is helpful. In addition, I don't understand why we should distinguish between Fixnum and Bignum. Isn't the difference just an implementation-defined technicality? I hope that they will be integrated to one class and that the difference will become invisible to users. I'm afraid if Fixnum::Max will make the integration difficult. -- Yusuke Endoh <mame@tsg.ne.jp> ---------------------------------------- Feature #7517: Fixnum::MIN,MAX https://bugs.ruby-lang.org/issues/7517#change-34480 Author: matz (Yukihiro Matsumoto) Status: Assigned Priority: Normal Assignee: matz (Yukihiro Matsumoto) Category: core Target version: 2.0.0 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
on 2012-12-06 16:38
Issue #7517 has been updated by matz (Yukihiro Matsumoto). It is especially useful for mruby that does not have Bignum, but I believe it's useful to tell how big fixnum is portable among Ruby implementations. Matz. ---------------------------------------- Feature #7517: Fixnum::MIN,MAX https://bugs.ruby-lang.org/issues/7517#change-34483 Author: matz (Yukihiro Matsumoto) Status: Assigned Priority: Normal Assignee: matz (Yukihiro Matsumoto) Category: core Target version: 2.0.0 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
on 2012-12-09 13:08
Issue #7517 has been updated by mame (Yusuke Endoh). Still, I'm not sure what problem (in mruby?) is resolved by the existence of Fixnum::MAX. How: n3 = n1 + n2 raise "unboxed" if n3 > Fixnum::MAX differs from: n3 = n1 + n2 raise "unboxed" if !n3.instance_of?(Fixnum) ? Just easier to read? -- Yusuke Endoh <mame@tsg.ne.jp> ---------------------------------------- Feature #7517: Fixnum::MIN,MAX https://bugs.ruby-lang.org/issues/7517#change-34553 Author: matz (Yukihiro Matsumoto) Status: Assigned Priority: Normal Assignee: matz (Yukihiro Matsumoto) Category: core Target version: 2.0.0 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
on 2012-12-10 06:27
Hi,
In message "Re: [ruby-core:50708] [ruby-trunk - Feature #7517]
Fixnum::MIN,MAX"
on Sun, 9 Dec 2012 21:07:37 +0900, "mame (Yusuke Endoh)"
<mame@tsg.ne.jp> writes:
|Still, I'm not sure what problem (in mruby?) is resolved by the existence of
Fixnum::MAX.
|
|How:
|
| n3 = n1 + n2
| raise "unboxed" if n3 > Fixnum::MAX
|
|differs from:
|
| n3 = n1 + n2
| raise "unboxed" if !n3.instance_of?(Fixnum)
|
|? Just easier to read?
For cases like the following:
printf "integers %d .. %d are unboxed\n", Fixnum::MIN, Fixnum::MAX
you don't have to create Fixnum instances.
matz.
on 2012-12-11 15:04
Issue #7517 has been updated by naruse (Yui NARUSE). What is the use case? If this is an mruby context, I suspect they should be Integer::MAX and Integer::MIN. ---------------------------------------- Feature #7517: Fixnum::MIN,MAX https://bugs.ruby-lang.org/issues/7517#change-34612 Author: matz (Yukihiro Matsumoto) Status: Assigned Priority: Normal Assignee: matz (Yukihiro Matsumoto) Category: core Target version: 2.0.0 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
on 2012-12-12 00:06
Hi,
In message "Re: [ruby-core:50760] [ruby-trunk - Feature #7517]
Fixnum::MIN,MAX"
on Tue, 11 Dec 2012 23:04:30 +0900, "naruse (Yui NARUSE)"
<naruse@airemix.jp> writes:
|What is the use case?
See #11 in portable way (i.e. portable among CRuby, JRuby, mruby, etc.)
|If this is an mruby context, I suspect they should be Integer::MAX and
Integer::MIN.
Maybe, since mruby doesn't have Bignum. But CRuby cannot have
Integer::MAX, so my intention to be portable will not be satisfied.
matz.
on 2012-12-13 02:36
Issue #7517 has been updated by tarui (Masaya Tarui). Hi, It cannot imagine except the use-case of liking to know how far an integer being treated. so, I think Integer::MAX better then Fixnum::MAX. CRuby's Integer::MAX is INFINITY,isn't it? If I introduce a Integer subclass for extending a digit number on mruby, is it a Fixnum? Currently, Fixnum can have instance, and It is an immediate class. But, Is Fixnum changed into an abstract class? ---------------------------------------- Feature #7517: Fixnum::MIN,MAX https://bugs.ruby-lang.org/issues/7517#change-34682 Author: matz (Yukihiro Matsumoto) Status: Assigned Priority: Normal Assignee: matz (Yukihiro Matsumoto) Category: core Target version: 2.0.0 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
on 2012-12-13 06:34
Hi,
In message "Re: [ruby-core:50849] [ruby-trunk - Feature #7517]
Fixnum::MIN,MAX"
on Thu, 13 Dec 2012 10:34:07 +0900, "tarui (Masaya Tarui)"
<tarui@prx.jp> writes:
|Hi,
|
|It cannot imagine except the use-case of liking to know how far an integer being
treated.
|so, I think Integer::MAX better then Fixnum::MAX.
|
|CRuby's Integer::MAX is INFINITY,isn't it?
INFINITY is a float. Are you proposing introducing Bignum::INFINITY?
In any way, Integer::MAX being (Bignum::)INFINITY do not have any
additional info than having Bignum. So I don't consider it useful.
|If I introduce a Integer subclass for extending a digit number on mruby, is it a
Fixnum?
|Currently, Fixnum can have instance, and It is an immediate class.
|But, Is Fixnum changed into an abstract class?
Fixnum is by definition immediate number, so that it has bound limit
(thus I proposal MIN and MAX for it). Integer is not. Even if I add
another immediate integer (say SmallInt a la Smalltalk) to mruby, it
has no relation to Fixnum.
matz.
on 2013-01-29 09:16
Issue #7517 has been updated by ko1 (Koichi Sasada). Target version changed from 2.0.0 to next minor ---------------------------------------- Feature #7517: Fixnum::MIN,MAX https://bugs.ruby-lang.org/issues/7517#change-35700 Author: matz (Yukihiro Matsumoto) Status: Assigned Priority: Normal Assignee: matz (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
Please log in before posting. Registration is free and takes only a minute.
Existing account
(Switch to SSL-encrypted connection)
NEW: Do you have a Google/GoogleMail or Yahoo account? No registration required!
Log in with Google account | Log in with Yahoo account
Log in with Google account | Log in with Yahoo account
No account? Register here.