Ruby
3.0.5p211 (2022-11-24 revision ba5cf0f7c52d4d35cc6a173c89eda98ceffa2dcf)
include
ruby
internal
arithmetic
fixnum.h
Go to the documentation of this file.
1
#ifndef RBIMPL_ARITHMETIC_FIXNUM_H
/*-*-C++-*-vi:se ft=cpp:*/
2
#define RBIMPL_ARITHMETIC_FIXNUM_H
23
#include "
ruby/backward/2/limits.h
"
24
25
#define FIXABLE RB_FIXABLE
26
#define FIXNUM_MAX RUBY_FIXNUM_MAX
27
#define FIXNUM_MIN RUBY_FIXNUM_MIN
28
#define NEGFIXABLE RB_NEGFIXABLE
29
#define POSFIXABLE RB_POSFIXABLE
30
31
/*
32
* FIXABLE can be applied to anything, from double to intmax_t. The problem is
33
* double. On a 64bit system RUBY_FIXNUM_MAX is 4,611,686,018,427,387,903,
34
* which is not representable by a double. The nearest value that a double can
35
* represent is 4,611,686,018,427,387,904, which is not fixable. The
36
* seemingly-stragne "< FIXNUM_MAX + 1" expression below is due to this.
37
*/
38
#define RB_POSFIXABLE(_) ((_) < RUBY_FIXNUM_MAX + 1)
39
#define RB_NEGFIXABLE(_) ((_) >= RUBY_FIXNUM_MIN)
40
#define RB_FIXABLE(_) (RB_POSFIXABLE(_) && RB_NEGFIXABLE(_))
41
#define RUBY_FIXNUM_MAX (LONG_MAX / 2)
42
#define RUBY_FIXNUM_MIN (LONG_MIN / 2)
43
44
#endif
/* RBIMPL_ARITHMETIC_FIXNUM_H */
limits.h
Historical shim for <limits.h>.
Generated by
1.9.5