Ruby
3.4.0dev (2024-12-06 revision 892c46283a5ea4179500d951c9d4866c0051f27b)
|
Arithmetic conversion between C's int
and Ruby's.
More...
#include "ruby/internal/config.h"
#include "ruby/internal/arithmetic/fixnum.h"
#include "ruby/internal/arithmetic/intptr_t.h"
#include "ruby/internal/arithmetic/long.h"
#include "ruby/internal/attr/artificial.h"
#include "ruby/internal/attr/const.h"
#include "ruby/internal/attr/constexpr.h"
#include "ruby/internal/compiler_is.h"
#include "ruby/internal/dllexport.h"
#include "ruby/internal/special_consts.h"
#include "ruby/internal/value.h"
#include "ruby/internal/warning_push.h"
#include "ruby/assert.h"
Go to the source code of this file.
Macros | |
#define | RB_INT2NUM rb_int2num_inline |
Just another name of rb_int2num_inline. More... | |
#define | RB_NUM2INT rb_num2int_inline |
Just another name of rb_num2int_inline. More... | |
#define | RB_UINT2NUM rb_uint2num_inline |
Just another name of rb_uint2num_inline. More... | |
#define | FIX2INT RB_FIX2INT |
Old name of RB_FIX2INT. More... | |
#define | FIX2UINT RB_FIX2UINT |
Old name of RB_FIX2UINT. More... | |
#define | INT2NUM RB_INT2NUM |
Old name of RB_INT2NUM. More... | |
#define | NUM2INT RB_NUM2INT |
Old name of RB_NUM2INT. More... | |
#define | NUM2UINT RB_NUM2UINT |
Old name of RB_NUM2UINT. More... | |
#define | UINT2NUM RB_UINT2NUM |
Old name of RB_UINT2NUM. More... | |
Functions | |
long | rb_num2int (VALUE num) |
Converts an instance of rb_cNumeric into C's long . More... | |
long | rb_fix2int (VALUE num) |
Identical to rb_num2int(). More... | |
unsigned long | rb_num2uint (VALUE num) |
Converts an instance of rb_cNumeric into C's unsigned long . More... | |
unsigned long | rb_fix2uint (VALUE num) |
Identical to rb_num2uint(). More... | |
static int | RB_FIX2INT (VALUE x) |
Converts a Fixnum into C's int . More... | |
static int | rb_num2int_inline (VALUE x) |
Converts an instance of rb_cNumeric into C's int . More... | |
static unsigned int | RB_NUM2UINT (VALUE x) |
Converts an instance of rb_cNumeric into C's unsigned int . More... | |
static unsigned int | RB_FIX2UINT (VALUE x) |
Converts a Fixnum into C's int . More... | |
static VALUE | rb_int2num_inline (int v) |
Converts a C's int into an instance of rb_cInteger. More... | |
static VALUE | rb_uint2num_inline (unsigned int v) |
Converts a C's unsigned int into an instance of rb_cInteger. More... | |
Arithmetic conversion between C's int
and Ruby's.
RBIMPL
or rbimpl
are implementation details. Don't take them as canon. They could rapidly appear then vanish. The name (path) of this header file is also an implementation detail. Do not expect it to persist at the place it is now. Developers are free to move it anywhere anytime at will. __VA_ARGS__
is always available. We assume C99 for ruby itself but we don't assume languages of extension libraries. They could be written in C++98. Definition in file int.h.
#define RB_INT2NUM rb_int2num_inline |
Just another name of rb_int2num_inline.
#define RB_NUM2INT rb_num2int_inline |
Just another name of rb_num2int_inline.
#define RB_UINT2NUM rb_uint2num_inline |
Just another name of rb_uint2num_inline.
long rb_fix2int | ( | VALUE | num | ) |
Identical to rb_num2int().
[in] | num | Something numeric. |
rb_eTypeError | num is not a numeric. |
rb_eRangeError | num is out of range of int . |
long
. Definition at line 3350 of file numeric.c.
Referenced by RB_FIX2INT(), and rb_num2int_inline().
|
inlinestatic |
unsigned long rb_fix2uint | ( | VALUE | num | ) |
Identical to rb_num2uint().
[in] | num | Something numeric. |
rb_eTypeError | num is not a numeric. |
rb_eRangeError | num is out of range of unsigned int . |
unsigned long
. Definition at line 3362 of file numeric.c.
Referenced by RB_FIX2UINT().
|
inlinestatic |
|
inlinestatic |
Converts a C's int
into an instance of rb_cInteger.
[in] | v | Arbitrary int value. |
long rb_num2int | ( | VALUE | num | ) |
Converts an instance of rb_cNumeric into C's long
.
[in] | num | Something numeric. |
rb_eTypeError | num is not a numeric. |
rb_eRangeError | num is out of range of int . |
long
. Definition at line 3344 of file numeric.c.
Referenced by rb_num2int_inline().
|
inlinestatic |
Converts an instance of rb_cNumeric into C's int
.
[in] | x | Something numeric. |
rb_eTypeError | x is not a numeric. |
rb_eRangeError | x is out of range of int . |
int
. unsigned long rb_num2uint | ( | VALUE | num | ) |
Converts an instance of rb_cNumeric into C's unsigned long
.
[in] | num | Something numeric. |
rb_eTypeError | num is not a numeric. |
rb_eRangeError | num is out of range of unsigned int . |
unsigned long
. Definition at line 3356 of file numeric.c.
Referenced by RB_NUM2UINT().
|
inlinestatic |
Converts an instance of rb_cNumeric into C's unsigned int
.
[in] | x | Something numeric. |
rb_eTypeError | x is not a numeric. |
rb_eRangeError | x is out of range of unsigned int . |
unsigned int
.
|
inlinestatic |
Converts a C's unsigned int
into an instance of rb_cInteger.
[in] | v | Arbitrary unsigned int value. |