w32tex
About: TeX Live provides a comprehensive TeX system including all the major TeX-related programs, macro packages, and fonts that are free software. Windows sources.
  Fossies Dox: w32tex-src.tar.xz  ("unofficial" and yet experimental doxygen-generated source code documentation)  

numeric.h File Reference
#include "common.h"
#include <stdint.h>
#include <float.h>
Include dependency graph for numeric.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Macros

#define TYPED_POSFIXABLE(f, t)   ((f) <= (t)MRB_FIXNUM_MAX)
 
#define TYPED_NEGFIXABLE(f, t)   ((f) >= (t)MRB_FIXNUM_MIN)
 
#define TYPED_FIXABLE(f, t)   (TYPED_POSFIXABLE(f,t) && TYPED_NEGFIXABLE(f,t))
 
#define POSFIXABLE(f)   TYPED_POSFIXABLE(f,mrb_int)
 
#define NEGFIXABLE(f)   TYPED_NEGFIXABLE(f,mrb_int)
 
#define FIXABLE(f)   TYPED_FIXABLE(f,mrb_int)
 
#define FIXABLE_FLOAT(f)   TYPED_FIXABLE(f,mrb_float)
 
#define __has_builtin(x)   0
 
#define MRB_INT_OVERFLOW_MASK   ((mrb_uint)1 << (MRB_INT_BIT - 1))
 
#define MRB_FLT_RADIX   FLT_RADIX
 
#define MRB_FLT_MANT_DIG   DBL_MANT_DIG
 
#define MRB_FLT_EPSILON   DBL_EPSILON
 
#define MRB_FLT_DIG   DBL_DIG
 
#define MRB_FLT_MIN_EXP   DBL_MIN_EXP
 
#define MRB_FLT_MIN   DBL_MIN
 
#define MRB_FLT_MIN_10_EXP   DBL_MIN_10_EXP
 
#define MRB_FLT_MAX_EXP   DBL_MAX_EXP
 
#define MRB_FLT_MAX   DBL_MAX
 
#define MRB_FLT_MAX_10_EXP   DBL_MAX_10_EXP
 

Functions

mrb_value mrb_flo_to_fixnum (mrb_state *mrb, mrb_value val)
 
mrb_value mrb_fixnum_to_str (mrb_state *mrb, mrb_value x, mrb_int base)
 
mrb_value mrb_float_to_str (mrb_state *mrb, mrb_value x, const char *fmt)
 
int mrb_float_to_cstr (mrb_state *mrb, char *buf, size_t len, const char *fmt, mrb_float f)
 
mrb_float mrb_to_flo (mrb_state *mrb, mrb_value x)
 
mrb_value mrb_num_plus (mrb_state *mrb, mrb_value x, mrb_value y)
 
mrb_value mrb_num_minus (mrb_state *mrb, mrb_value x, mrb_value y)
 
mrb_value mrb_num_mul (mrb_state *mrb, mrb_value x, mrb_value y)
 
static mrb_bool mrb_int_add_overflow (mrb_int a, mrb_int b, mrb_int *c)
 
static mrb_bool mrb_int_sub_overflow (mrb_int a, mrb_int b, mrb_int *c)
 
static mrb_bool mrb_int_mul_overflow (mrb_int a, mrb_int b, mrb_int *c)
 

Detailed Description

  • Numeric, Integer, Float class

See Copyright Notice in mruby.h

Definition in file numeric.h.

Macro Definition Documentation

◆ __has_builtin

#define __has_builtin (   x)    0

Definition at line 49 of file numeric.h.

◆ FIXABLE

#define FIXABLE (   f)    TYPED_FIXABLE(f,mrb_int)

Definition at line 24 of file numeric.h.

◆ FIXABLE_FLOAT

#define FIXABLE_FLOAT (   f)    TYPED_FIXABLE(f,mrb_float)

Definition at line 29 of file numeric.h.

◆ MRB_FLT_DIG

#define MRB_FLT_DIG   DBL_DIG

Definition at line 157 of file numeric.h.

◆ MRB_FLT_EPSILON

#define MRB_FLT_EPSILON   DBL_EPSILON

Definition at line 156 of file numeric.h.

◆ MRB_FLT_MANT_DIG

#define MRB_FLT_MANT_DIG   DBL_MANT_DIG

Definition at line 155 of file numeric.h.

◆ MRB_FLT_MAX

#define MRB_FLT_MAX   DBL_MAX

Definition at line 162 of file numeric.h.

◆ MRB_FLT_MAX_10_EXP

#define MRB_FLT_MAX_10_EXP   DBL_MAX_10_EXP

Definition at line 163 of file numeric.h.

◆ MRB_FLT_MAX_EXP

#define MRB_FLT_MAX_EXP   DBL_MAX_EXP

Definition at line 161 of file numeric.h.

◆ MRB_FLT_MIN

#define MRB_FLT_MIN   DBL_MIN

Definition at line 159 of file numeric.h.

◆ MRB_FLT_MIN_10_EXP

#define MRB_FLT_MIN_10_EXP   DBL_MIN_10_EXP

Definition at line 160 of file numeric.h.

◆ MRB_FLT_MIN_EXP

#define MRB_FLT_MIN_EXP   DBL_MIN_EXP

Definition at line 158 of file numeric.h.

◆ MRB_FLT_RADIX

#define MRB_FLT_RADIX   FLT_RADIX

Definition at line 141 of file numeric.h.

◆ MRB_INT_OVERFLOW_MASK

#define MRB_INT_OVERFLOW_MASK   ((mrb_uint)1 << (MRB_INT_BIT - 1))

Definition at line 93 of file numeric.h.

◆ NEGFIXABLE

#define NEGFIXABLE (   f)    TYPED_NEGFIXABLE(f,mrb_int)

Definition at line 23 of file numeric.h.

◆ POSFIXABLE

#define POSFIXABLE (   f)    TYPED_POSFIXABLE(f,mrb_int)

Definition at line 22 of file numeric.h.

◆ TYPED_FIXABLE

#define TYPED_FIXABLE (   f,
  t 
)    (TYPED_POSFIXABLE(f,t) && TYPED_NEGFIXABLE(f,t))

Definition at line 21 of file numeric.h.

◆ TYPED_NEGFIXABLE

#define TYPED_NEGFIXABLE (   f,
  t 
)    ((f) >= (t)MRB_FIXNUM_MIN)

Definition at line 20 of file numeric.h.

◆ TYPED_POSFIXABLE

#define TYPED_POSFIXABLE (   f,
  t 
)    ((f) <= (t)MRB_FIXNUM_MAX)

Numeric class and it's sub-classes.

Integer and Float

Definition at line 19 of file numeric.h.

Function Documentation

◆ mrb_fixnum_to_str()

◆ mrb_flo_to_fixnum()

◆ mrb_float_to_cstr()

int mrb_float_to_cstr ( mrb_state mrb,
char *  buf,
size_t  len,
const char *  fmt,
mrb_float  f 
)

Definition at line 458 of file fmt_fp.c.

References buf, fmt, len, and snprintf.

Referenced by mrb_str_format().

◆ mrb_float_to_str()

mrb_value mrb_float_to_str ( mrb_state mrb,
mrb_value  x,
const char *  fmt 
)

Definition at line 449 of file fmt_fp.c.

References buf, fmt, mrb_str_new_cstr(), and snprintf.

Referenced by flo_to_s().

◆ mrb_int_add_overflow()

static mrb_bool mrb_int_add_overflow ( mrb_int  a,
mrb_int  b,
mrb_int c 
)
inlinestatic

Definition at line 96 of file numeric.h.

References a, b, c, MRB_INT_OVERFLOW_MASK, cordic::x, y, and z.

Referenced by fixnum_plus().

◆ mrb_int_mul_overflow()

static mrb_bool mrb_int_mul_overflow ( mrb_int  a,
mrb_int  b,
mrb_int c 
)
inlinestatic

Definition at line 116 of file numeric.h.

References a, b, c, FALSE, int64_t, MRB_INT_MAX, MRB_INT_MIN, n, and TRUE.

Referenced by fixnum_mul(), get_num(), int_pow(), and mrb_str_len_to_inum().

◆ mrb_int_sub_overflow()

static mrb_bool mrb_int_sub_overflow ( mrb_int  a,
mrb_int  b,
mrb_int c 
)
inlinestatic

Definition at line 106 of file numeric.h.

References a, b, c, MRB_INT_OVERFLOW_MASK, cordic::x, y, and z.

Referenced by fixnum_minus().

◆ mrb_num_minus()

◆ mrb_num_mul()

◆ mrb_num_plus()

◆ mrb_to_flo()