зеркало из https://github.com/github/ruby.git
* include/ruby/ruby.h (POSFIXABLE): use FIXNUM_MAX+1 instead of
FIXNUM_MAX to make it possible to convert to double accurately. It assumes FLT_RADIX is 2. fix RubyForge bug #14102. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@16226 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
Родитель
6837681a4c
Коммит
6daf556345
|
@ -1,3 +1,10 @@
|
|||
Mon Apr 28 14:21:18 2008 Tanaka Akira <akr@fsij.org>
|
||||
|
||||
* include/ruby/ruby.h (POSFIXABLE): use FIXNUM_MAX+1 instead of
|
||||
FIXNUM_MAX to make it possible to convert to double accurately.
|
||||
It assumes FLT_RADIX is 2.
|
||||
fix RubyForge bug #14102.
|
||||
|
||||
Mon Apr 28 12:48:57 2008 NAKAMURA Usaku <usa@ruby-lang.org>
|
||||
|
||||
* process.c (rb_exec_arg_addopt, rb_exec_arg_addopt): now can specify
|
||||
|
|
|
@ -193,7 +193,7 @@ VALUE rb_ull2inum(unsigned LONG_LONG);
|
|||
#define FIX2LONG(x) RSHIFT((SIGNED_VALUE)x,1)
|
||||
#define FIX2ULONG(x) ((((VALUE)(x))>>1)&LONG_MAX)
|
||||
#define FIXNUM_P(f) (((SIGNED_VALUE)(f))&FIXNUM_FLAG)
|
||||
#define POSFIXABLE(f) ((f) <= FIXNUM_MAX)
|
||||
#define POSFIXABLE(f) ((f) < FIXNUM_MAX+1)
|
||||
#define NEGFIXABLE(f) ((f) >= FIXNUM_MIN)
|
||||
#define FIXABLE(f) (POSFIXABLE(f) && NEGFIXABLE(f))
|
||||
|
||||
|
|
|
@ -277,4 +277,38 @@ class TestFloat < Test::Unit::TestCase
|
|||
assert_equal(1.0, Float.induced_from(1.0))
|
||||
assert_raise(TypeError) { Float.induced_from(nil) }
|
||||
end
|
||||
|
||||
def test_to_i
|
||||
assert_operator(4611686018427387905.0.to_i, :>, 0)
|
||||
assert_operator(4611686018427387904.0.to_i, :>, 0)
|
||||
assert_operator(4611686018427387903.8.to_i, :>, 0)
|
||||
assert_operator(4611686018427387903.5.to_i, :>, 0)
|
||||
assert_operator(4611686018427387903.2.to_i, :>, 0)
|
||||
assert_operator(4611686018427387903.0.to_i, :>, 0)
|
||||
assert_operator(4611686018427387902.0.to_i, :>, 0)
|
||||
|
||||
assert_operator(1073741825.0.to_i, :>, 0)
|
||||
assert_operator(1073741824.0.to_i, :>, 0)
|
||||
assert_operator(1073741823.8.to_i, :>, 0)
|
||||
assert_operator(1073741823.5.to_i, :>, 0)
|
||||
assert_operator(1073741823.2.to_i, :>, 0)
|
||||
assert_operator(1073741823.0.to_i, :>, 0)
|
||||
assert_operator(1073741822.0.to_i, :>, 0)
|
||||
|
||||
assert_operator((-1073741823.0).to_i, :<, 0)
|
||||
assert_operator((-1073741824.0).to_i, :<, 0)
|
||||
assert_operator((-1073741824.2).to_i, :<, 0)
|
||||
assert_operator((-1073741824.5).to_i, :<, 0)
|
||||
assert_operator((-1073741824.8).to_i, :<, 0)
|
||||
assert_operator((-1073741825.0).to_i, :<, 0)
|
||||
assert_operator((-1073741826.0).to_i, :<, 0)
|
||||
|
||||
assert_operator((-4611686018427387903.0).to_i, :<, 0)
|
||||
assert_operator((-4611686018427387904.0).to_i, :<, 0)
|
||||
assert_operator((-4611686018427387904.2).to_i, :<, 0)
|
||||
assert_operator((-4611686018427387904.5).to_i, :<, 0)
|
||||
assert_operator((-4611686018427387904.8).to_i, :<, 0)
|
||||
assert_operator((-4611686018427387905.0).to_i, :<, 0)
|
||||
assert_operator((-4611686018427387906.0).to_i, :<, 0)
|
||||
end
|
||||
end
|
||||
|
|
Загрузка…
Ссылка в новой задаче