Main Page | Modules | Alphabetical List | Data Structures | File List | Data Fields | Globals

Numeric
[Ruby]


Modules

Bignum
Numeric

C Data to Fixnum or Bignum Coversion Routines

#define INT2FIX(i)   ((VALUE)(((long)(i))<<1 | FIXNUM_FLAG))
#define LONG2FIX(i)   INT2FIX(i)
#define rb_fix_new(v)   INT2FIX(v)
#define INT2NUM(v)   rb_int2inum(v)
#define LONG2NUM(v)   INT2NUM(v)
#define rb_int_new(v)   rb_int2inum(v)
#define UINT2NUM(v)   rb_uint2inum(v)
#define ULONG2NUM(v)   UINT2NUM(v)
#define rb_uint_new(v)   rb_uint2inum(v)
#define LL2NUM(v)   rb_ll2inum(v)
#define ULL2NUM(v)   rb_ull2inum(v)
#define OFFT2NUM(v)   LL2NUM(v)
#define FIX2LONG(x)   RSHIFT((long)x,1)
#define FIX2ULONG(x)   (((unsigned long)(x))>>1)
#define FIXNUM_P(f)   (((long)(f))&FIXNUM_FLAG)
#define POSFIXABLE(f)   ((f) <= FIXNUM_MAX)
#define NEGFIXABLE(f)   ((f) >= FIXNUM_MIN)
#define FIXABLE(f)   (POSFIXABLE(f) && NEGFIXABLE(f))
VALUE rb_int2inum (long)
VALUE rb_uint2inum (unsigned long)
VALUE rb_ll2inum (LONG_LONG)
VALUE rb_ull2inum (unsigned LONG_LONG)

Fixnum or Bignum to C Data Coversion Routines

#define NUM2LONG(x)   (FIXNUM_P(x)?FIX2LONG(x):rb_num2long((VALUE)x))
#define NUM2ULONG(x)   rb_num2ulong((VALUE)x)
#define NUM2INT(x)   ((int)NUM2LONG(x))
#define NUM2UINT(x)   ((unsigned int)NUM2ULONG(x))
#define FIX2INT(x)   ((int)FIX2LONG(x))
#define FIX2UINT(x)   ((unsigned int)FIX2ULONG(x))
#define NUM2LL(x)   (FIXNUM_P(x)?FIX2LONG(x):rb_num2ll((VALUE)x))
#define NUM2OFFT(x)   ((off_t)NUM2LL(x))
long rb_num2long (VALUE)
unsigned long rb_num2ulong (VALUE)
LONG_LONG rb_num2ll (VALUE)
unsigned LONG_LONG rb_num2ull (VALUE)

Double Conversion Routines

#define NUM2DBL(x)   rb_num2dbl((VALUE)(x))
double rb_num2dbl (VALUE)


Define Documentation

#define FIX2INT  )     ((int)FIX2LONG(x))
 

Definition at line 284 of file ruby.h.

Referenced by fix_to_s(), marshal_dump(), match_aref(), proc_setgroups(), proc_setmaxgroups(), r_byte(), rb_cmpint(), rb_f_kill(), rb_fix2int(), rb_io_s_popen(), rb_io_s_sysopen(), rb_open_file(), rb_reg_initialize_m(), rb_str_aset(), rb_str_concat(), rb_str_include(), rb_str_index_m(), rb_str_rindex_m(), run_final(), trap(), and w_object().

#define FIX2LONG  )     RSHIFT((long)x,1)
 

Definition at line 149 of file ruby.h.

Referenced by fix_abs(), fix_and(), fix_aref(), fix_cmp(), fix_div(), fix_divmod(), fix_equal(), fix_ge(), fix_gt(), fix_le(), fix_lt(), fix_minus(), fix_mod(), fix_mul(), fix_or(), fix_plus(), fix_pow(), fix_quo(), fix_rev(), fix_rshift(), fix_to_f(), fix_uminus(), fix_xor(), fix_zero_p(), flo_cmp(), flo_div(), flo_divmod(), flo_eq(), flo_ge(), flo_gt(), flo_le(), flo_lt(), flo_minus(), flo_mod(), flo_mul(), flo_plus(), flo_pow(), int_dotimes(), int_downto(), int_succ(), int_upto(), negate_lit(), num2i32(), num_step(), range_each(), range_step(), rb_any_hash(), rb_ary_aref(), rb_ary_aset(), rb_big_and(), rb_big_cmp(), rb_big_coerce(), rb_big_div(), rb_big_divmod(), rb_big_eq(), rb_big_minus(), rb_big_modulo(), rb_big_mul(), rb_big_or(), rb_big_plus(), rb_big_pow(), rb_big_quo(), rb_big_remainder(), rb_big_xor(), rb_f_rand(), rb_f_sprintf(), rb_fix2str(), rb_Float(), rb_io_ctl(), rb_io_initialize(), rb_num2ll(), rb_num2long(), rb_quad_pack(), rb_str_aref(), rb_str_aset(), rb_str_cmp_m(), rb_struct_initialize(), rb_struct_new(), rb_to_id(), rb_values_at(), struct_alloc(), and w_object().

#define FIX2UINT  )     ((unsigned int)FIX2ULONG(x))
 

Definition at line 285 of file ruby.h.

Referenced by fix_id2name(), and fix_to_sym().

#define FIX2ULONG  )     (((unsigned long)(x))>>1)
 

Definition at line 150 of file ruby.h.

Referenced by rand_init().

#define FIXABLE  )     (POSFIXABLE(f) && NEGFIXABLE(f))
 

Definition at line 154 of file ruby.h.

Referenced by flo_ceil(), flo_floor(), flo_round(), flo_truncate(), rb_int2inum(), rb_ll2inum(), rb_num2fix(), and rb_quad_unpack().

#define FIXNUM_P  )     (((long)(f))&FIXNUM_FLAG)
 

Definition at line 151 of file ruby.h.

Referenced by bignorm(), exit_initialize(), fix_aref(), fix_cmp(), fix_div(), fix_divmod(), fix_equal(), fix_ge(), fix_gt(), fix_le(), fix_lt(), fix_minus(), fix_mod(), fix_mul(), fix_plus(), fix_pow(), fix_quo(), id2ref(), int_dotimes(), int_downto(), int_succ(), int_upto(), marshal_dump(), match_aref(), num2i32(), num_step(), proc_setgroups(), rand_init(), range_each(), range_init(), range_op(), range_step(), rb_any_cmp(), rb_any_hash(), rb_ary_aref(), rb_ary_aset(), rb_ary_initialize(), rb_ary_slice_bang(), rb_big2str(), rb_big_and(), rb_big_coerce(), rb_big_mul(), rb_big_or(), rb_big_xor(), rb_check_type(), rb_class_of(), rb_cmpint(), rb_eval(), rb_f_rand(), rb_f_sprintf(), rb_io_ctl(), rb_io_initialize(), rb_io_s_popen(), rb_io_s_sysopen(), rb_num2fix(), rb_num2ll(), rb_num2long(), rb_obj_instance_eval(), rb_open_file(), rb_quad_pack(), rb_reg_initialize_m(), rb_singleton_class(), rb_str_aset(), rb_str_cmp_m(), rb_str_concat(), rb_str_include(), rb_type(), rb_values_at(), sort_2(), syserr_eqq(), syserr_initialize(), w_object(), and yyparse().

#define INT2FIX  )     ((VALUE)(((long)(i))<<1 | FIXNUM_FLAG))
 

Definition at line 124 of file ruby.h.

Referenced by argf_getline(), argf_set_lineno(), call_trace_func(), define_final(), dir_s_chdir(), dir_s_chroot(), dir_s_mkdir(), dir_s_rmdir(), each_with_index_i(), env_size(), exit_initialize(), exit_success_p(), fix_aref(), fix_cmp(), fix_pow(), fix_rshift(), fix_size(), flo_hash(), flo_is_infinite_p(), get_pid(), get_ppid(), gettable(), Init_File(), Init_IO(), Init_marshal(), Init_Numeric(), Init_process(), Init_Regexp(), int_dotimes(), int_downto(), int_succ(), int_upto(), io_write(), last_status_set(), lineno_setter(), load_file(), match_begin(), match_end(), match_offset(), match_size(), method_arity(), nil_to_i(), num_abs(), num_cmp(), num_remainder(), num_step(), num_uminus(), num_zero_p(), os_live_obj(), os_obj_of(), p_gid_change_privilege(), p_gid_exchange(), p_gid_switch(), p_uid_change_privilege(), p_uid_exchange(), p_uid_switch(), pack_unpack(), proc_arity(), proc_getegid(), proc_geteuid(), proc_getgid(), proc_getmaxgroups(), proc_getpgrp(), proc_getpriority(), proc_getuid(), proc_setgid(), proc_setmaxgroups(), proc_setpgid(), proc_setpgrp(), proc_setpriority(), proc_setsid(), proc_setuid(), proc_wait(), r_entry(), r_le(), range_each_func(), range_step(), rb_any_hash(), rb_ary_cmp(), rb_big_aref(), rb_big_cmp(), rb_big_lshift(), rb_big_pow(), rb_big_rshift(), rb_cmpint(), rb_cstr_to_inum(), rb_dbl_cmp(), rb_f_fork(), rb_f_kill(), rb_f_rand(), rb_f_sleep(), rb_file_chmod(), rb_file_chown(), rb_file_flock(), rb_file_s_link(), rb_file_s_rename(), rb_file_s_symlink(), rb_file_s_truncate(), rb_file_s_umask(), rb_file_truncate(), rb_gets(), rb_hash_size(), rb_io_each_byte(), rb_io_fileno(), rb_io_fsync(), rb_io_getc(), rb_io_getline(), rb_io_getline_fast(), rb_io_pid(), rb_io_rewind(), rb_io_s_pipe(), rb_io_seek(), rb_mod_cmp(), rb_reg_hash(), rb_setegid_core(), rb_seteuid_core(), rb_stat_cmp(), rb_str_aref(), rb_str_casecmp(), rb_str_count(), rb_str_each_byte(), rb_str_hash_m(), rb_str_sum(), rb_thread_sleep(), rb_trap_eval(), rb_trap_exit(), sig_list(), time_cmp(), time_hour(), time_mday(), time_min(), time_mon(), time_sec(), time_to_a(), time_utc_offset(), time_wday(), and time_yday().

#define INT2NUM  )     rb_int2inum(v)
 

Definition at line 128 of file ruby.h.

Referenced by argf_read(), math_frexp(), pack_unpack(), proc_getgroups(), proc_getpgid(), proc_waitall(), pst_bitand(), pst_rshift(), pst_wexitstatus(), pst_wstopsig(), pst_wtermsig(), rb_f_syscall(), rb_io_ctl(), rb_io_lineno(), rb_io_s_pipe(), rb_io_s_sysopen(), rb_reg_options_m(), rb_stat_dev(), rb_str_count(), rb_thread_priority(), rb_thread_safe_level(), rb_thread_signal_exit(), safe_getter(), set_syserr(), terminate_process(), time_utc_offset(), and w_object().

#define LL2NUM  )     rb_ll2inum(v)
 

Definition at line 138 of file ruby.h.

#define LONG2FIX  )     INT2FIX(i)
 

Definition at line 125 of file ruby.h.

Referenced by bignorm(), fix_lshift(), fix_minus(), fix_mul(), fix_plus(), fix_rshift(), flo_ceil(), flo_floor(), flo_round(), flo_truncate(), int_dotimes(), int_downto(), int_upto(), io_write(), negate_lit(), num_step(), r_object0(), range_hash(), rb_ary_hash(), rb_big_hash(), rb_big_size(), rb_cstr_to_inum(), rb_file_s_chmod(), rb_file_s_chown(), rb_file_s_lchown(), rb_file_s_unlink(), rb_file_s_utime(), rb_int2inum(), rb_io_syswrite(), rb_ll2inum(), rb_num2fix(), rb_quad_unpack(), rb_reg_match(), rb_reg_match2(), rb_str_cmp_m(), rb_struct_hash(), rb_struct_size(), rb_uint2inum(), rb_ull2inum(), sym_to_i(), time_hash(), and time_utc_offset().

#define LONG2NUM  )     INT2NUM(v)
 

Definition at line 129 of file ruby.h.

Referenced by fix_abs(), fix_and(), fix_div(), fix_divmod(), fix_lshift(), fix_mod(), fix_or(), fix_rev(), fix_uminus(), fix_xor(), int_succ(), make_struct(), pack_unpack(), r_bytes0(), range_each(), range_step(), rb_ary_each_index(), rb_ary_fill(), rb_ary_index(), rb_ary_initialize(), rb_ary_length(), rb_ary_nitems(), rb_ary_rindex(), rb_f_rand(), rb_obj_id(), rb_require_safe(), rb_str_cmp_m(), rb_str_index_m(), rb_str_length(), rb_str_rindex_m(), struct_entry(), time_to_a(), time_to_i(), time_usec(), and time_year().

#define NEGFIXABLE  )     ((f) >= FIXNUM_MIN)
 

Definition at line 153 of file ruby.h.

Referenced by bignorm().

#define NUM2DBL  )     rb_num2dbl((VALUE)(x))
 

Definition at line 304 of file ruby.h.

Referenced by num_step(), and time_add().

#define NUM2INT  )     ((int)NUM2LONG(x))
 

Definition at line 282 of file ruby.h.

Referenced by argf_set_lineno(), dir_s_mkdir(), fix_to_s(), lineno_setter(), marshal_dump(), match_begin(), match_end(), match_offset(), math_ldexp(), p_gid_change_privilege(), p_gid_grant_privilege(), p_sys_setegid(), p_sys_seteuid(), p_sys_setgid(), p_sys_setregid(), p_sys_setresgid(), p_sys_setresuid(), p_sys_setreuid(), p_sys_setrgid(), p_sys_setruid(), p_sys_setuid(), p_uid_change_privilege(), p_uid_grant_privilege(), pack_pack(), proc_detach(), proc_getpgid(), proc_getpriority(), proc_initgroups(), proc_setegid(), proc_seteuid(), proc_setgid(), proc_setgroups(), proc_setpgid(), proc_setpriority(), proc_setuid(), proc_wait(), pst_bitand(), pst_inspect(), pst_rshift(), pst_success_p(), pst_wcoredump(), pst_wexitstatus(), pst_wifexited(), pst_wifsignaled(), pst_wifstopped(), pst_wstopsig(), pst_wtermsig(), rb_big_aref(), rb_big_lshift(), rb_big_rshift(), rb_big_to_s(), rb_f_caller(), rb_f_eval(), rb_f_exit(), rb_f_exit_bang(), rb_f_kill(), rb_f_sprintf(), rb_f_system(), rb_file_chmod(), rb_file_chown(), rb_file_flock(), rb_file_s_chmod(), rb_file_s_chown(), rb_file_s_lchown(), rb_file_s_umask(), rb_io_initialize(), rb_io_s_sysopen(), rb_io_seek_m(), rb_io_set_lineno(), rb_io_sysseek(), rb_io_ungetc(), rb_open_file(), rb_reg_s_last_match(), rb_str_aref_m(), rb_str_aset_m(), rb_str_split_m(), rb_str_sum(), rb_str_to_i(), rb_thread_priority_set(), ruby_cleanup(), safe_setter(), specific_eval(), and sysexit_status().

#define NUM2LL  )     (FIXNUM_P(x)?FIX2LONG(x):rb_num2ll((VALUE)x))
 

Definition at line 291 of file ruby.h.

Referenced by rb_num2ll().

#define NUM2LONG  )     (FIXNUM_P(x)?FIX2LONG(x):rb_num2long((VALUE)x))
 

Definition at line 270 of file ruby.h.

Referenced by argf_read(), fix_and(), fix_aref(), fix_lshift(), fix_or(), fix_rshift(), fix_xor(), int_chr(), io_getpartial(), io_read(), obj2long(), pack_pack(), pst_inspect(), range_step(), rb_ary_aref(), rb_ary_aset(), rb_ary_at(), rb_ary_delete_at_m(), rb_ary_fetch(), rb_ary_fill(), rb_ary_first(), rb_ary_hash(), rb_ary_initialize(), rb_ary_insert(), rb_ary_last(), rb_ary_slice_bang(), rb_ary_times(), rb_f_syscall(), rb_io_ctl(), rb_io_sysread(), rb_num2long(), rb_range_beg_len(), rb_str_aref(), rb_str_aref_m(), rb_str_aset(), rb_str_aset_m(), rb_str_index_m(), rb_str_insert(), rb_str_justify(), rb_str_rindex_m(), rb_str_times(), rb_struct_aref(), rb_struct_aset(), rb_struct_hash(), rb_values_at(), syserr_initialize(), and time_s_at().

#define NUM2OFFT  )     ((off_t)NUM2LL(x))
 

Definition at line 295 of file ruby.h.

Referenced by dir_seek(), rb_file_s_truncate(), rb_file_truncate(), rb_io_seek(), rb_io_set_pos(), and rb_io_sysseek().

#define NUM2UINT  )     ((unsigned int)NUM2ULONG(x))
 

Definition at line 283 of file ruby.h.

Referenced by proc_wait().

#define NUM2ULONG  )     rb_num2ulong((VALUE)x)
 

Definition at line 271 of file ruby.h.

Referenced by id2ref(), rb_io_ctl(), and rb_stat_inspect().

#define OFFT2NUM  )     LL2NUM(v)
 

Definition at line 144 of file ruby.h.

Referenced by rb_file_s_size(), rb_io_set_pos(), rb_io_sysseek(), rb_io_tell(), rb_stat_s(), rb_stat_size(), and test_s().

#define POSFIXABLE  )     ((f) <= FIXNUM_MAX)
 

Definition at line 152 of file ruby.h.

Referenced by bignorm(), dbl2big(), rb_cstr_to_inum(), rb_quad_unpack(), rb_uint2inum(), and rb_ull2inum().

#define rb_fix_new  )     INT2FIX(v)
 

Definition at line 126 of file ruby.h.

#define rb_int_new  )     rb_int2inum(v)
 

Definition at line 130 of file ruby.h.

#define rb_uint_new  )     rb_uint2inum(v)
 

Definition at line 134 of file ruby.h.

#define UINT2NUM  )     rb_uint2inum(v)
 

Definition at line 132 of file ruby.h.

Referenced by pack_unpack(), rb_stat_gid(), rb_stat_mode(), rb_stat_nlink(), and rb_stat_uid().

#define ULL2NUM  )     rb_ull2inum(v)
 

Definition at line 140 of file ruby.h.

Referenced by rb_stat_ino().

#define ULONG2NUM  )     UINT2NUM(v)
 

Definition at line 133 of file ruby.h.

Referenced by pack_unpack(), rb_stat_blksize(), rb_stat_blocks(), rb_stat_dev_major(), rb_stat_dev_minor(), rb_stat_ino(), rb_stat_rdev(), rb_stat_rdev_major(), and rb_stat_rdev_minor().


Function Documentation

VALUE rb_int2inum long   ) 
 

Definition at line 181 of file bignum.c.

References FIXABLE, LONG2FIX, and rb_int2big().

Referenced by dir_tell(), and rb_str_sum().

VALUE rb_ll2inum LONG_LONG   ) 
 

Definition at line 590 of file bignum.c.

References FIXABLE, LONG2FIX, and rb_ll2big().

double rb_num2dbl VALUE   ) 
 

Definition at line 2395 of file object.c.

References rb_eTypeError, rb_Float(), rb_raise(), RFLOAT, T_FLOAT, T_NIL, T_STRING, TYPE, and VALUE.

Referenced by rb_thread_join_m().

LONG_LONG rb_num2ll VALUE   ) 
 

Definition at line 1656 of file numeric.c.

References FIX2LONG, FIXNUM_P, LLONG_MAX, LLONG_MIN, NIL_P, NUM2LL, Qnil, rb_big2ll(), rb_eRangeError, rb_eTypeError, rb_raise(), rb_to_int(), RFLOAT, strchr(), T_BIGNUM, T_FALSE, T_FLOAT, T_STRING, T_TRUE, TYPE, and VALUE.

Referenced by rb_num2ull().

long rb_num2long VALUE   ) 
 

Definition at line 1505 of file numeric.c.

References FIX2LONG, FIXNUM_P, LONG_MIN, NIL_P, NUM2LONG, rb_big2long(), rb_eRangeError, rb_eTypeError, rb_raise(), rb_to_int(), RFLOAT, strchr(), T_BIGNUM, T_FLOAT, TYPE, and VALUE.

Referenced by rb_num2fix(), rb_num2int(), and rb_num2ulong().

unsigned LONG_LONG rb_num2ull VALUE   ) 
 

Definition at line 1699 of file numeric.c.

References rb_big2ull(), rb_num2ll(), T_BIGNUM, TYPE, and VALUE.

unsigned long rb_num2ulong VALUE   ) 
 

Definition at line 1539 of file numeric.c.

References rb_big2ulong(), rb_num2long(), T_BIGNUM, TYPE, and VALUE.

VALUE rb_uint2inum unsigned  long  ) 
 

Definition at line 173 of file bignum.c.

References LONG2FIX, POSFIXABLE, and rb_uint2big().

VALUE rb_ull2inum unsigned  LONG_LONG  ) 
 

Definition at line 582 of file bignum.c.

References LONG2FIX, POSFIXABLE, and rb_ull2big().


Generated on Wed Jan 18 23:32:12 2006 for Ruby by doxygen 1.3.5