CUBRID Engine  latest
numeric_opfunc.c File Reference
#include <float.h>
#include <math.h>
#include <assert.h>
#include <stdio.h>
#include <string.h>
#include "mprec.h"
#include "numeric_opfunc.h"
#include "tz_support.h"
#include "db_date.h"
#include "memory_alloc.h"
#include "system_parameter.h"
#include "byte_order.h"
#include "object_primitive.h"
#include "object_representation.h"
#include "dbtype.h"
Include dependency graph for numeric_opfunc.c:

Go to the source code of this file.

Classes

struct  dec_string
 

Macros

#define DB_LONG_NUMERIC_MULTIPLIER   2
 
#define CARRYOVER(arg)   ((arg) >> 8)
 
#define GET_LOWER_BYTE(arg)   ((arg) & 0xff)
 
#define NUMERIC_ABS(a)   ((a) >= 0 ? a : -a)
 
#define TWICE_NUM_MAX_PREC   (2*DB_MAX_NUMERIC_PRECISION)
 
#define SECONDS_IN_A_DAY   (int)(24L * 60L * 60L)
 
#define ROUND(x)   ((x) > 0 ? ((x) + .5) : ((x) - .5))
 

Typedefs

typedef struct dec_string DEC_STRING
 
typedef enum fp_value_type FP_VALUE_TYPE
 

Enumerations

enum  fp_value_type { FP_VALUE_TYPE_NUMBER, FP_VALUE_TYPE_INFINITE, FP_VALUE_TYPE_NAN, FP_VALUE_TYPE_ZERO }
 

Functions

static bool numeric_is_negative (DB_C_NUMERIC arg)
 
static void numeric_copy (DB_C_NUMERIC dest, DB_C_NUMERIC source)
 
static void numeric_copy_long (DB_C_NUMERIC dest, DB_C_NUMERIC source, bool is_long_num)
 
static void numeric_increase (DB_C_NUMERIC answer)
 
static void numeric_increase_long (DB_C_NUMERIC answer, bool is_long_num)
 
static void numeric_decrease (DB_C_NUMERIC answer)
 
static void numeric_zero (DB_C_NUMERIC answer, int size)
 
static void numeric_init_dec_str (DEC_STRING *answer)
 
static void numeric_add_dec_str (DEC_STRING *arg1, DEC_STRING *arg2, DEC_STRING *answer)
 
static void numeric_init_pow_of_2_helper (void)
 
static DEC_STRINGnumeric_get_pow_of_2 (int exp)
 
static void numeric_init_pow_of_10_helper (void)
 
static DB_C_NUMERIC numeric_get_pow_of_10 (int exp)
 
static void numeric_double_shift_bit (DB_C_NUMERIC arg1, DB_C_NUMERIC arg2, int numbits, DB_C_NUMERIC lsb, DB_C_NUMERIC msb, bool is_long_num)
 
static int numeric_compare_pos (DB_C_NUMERIC arg1, DB_C_NUMERIC arg2)
 
static void numeric_negate (DB_C_NUMERIC answer)
 
static void numeric_negate_long (DB_C_NUMERIC answer, bool is_long_num)
 
static void numeric_shift_byte (DB_C_NUMERIC arg, int numbytes, DB_C_NUMERIC answer, int length)
 
static bool numeric_is_zero (DB_C_NUMERIC arg)
 
static bool numeric_is_long (DB_C_NUMERIC arg)
 
static bool numeric_is_bigint (DB_C_NUMERIC arg)
 
static bool numeric_is_bit_set (DB_C_NUMERIC arg, int pos)
 
static bool numeric_overflow (DB_C_NUMERIC arg, int exp)
 
static void numeric_add (DB_C_NUMERIC arg1, DB_C_NUMERIC arg2, DB_C_NUMERIC answer, int size)
 
static void numeric_sub (DB_C_NUMERIC arg1, DB_C_NUMERIC arg2, DB_C_NUMERIC answer, int size)
 
static void numeric_mul (DB_C_NUMERIC a1, DB_C_NUMERIC a2, bool *positive_flag, DB_C_NUMERIC answer)
 
static void numeric_long_div (DB_C_NUMERIC a1, DB_C_NUMERIC a2, DB_C_NUMERIC answer, DB_C_NUMERIC remainder, bool is_long_num)
 
static void numeric_div (DB_C_NUMERIC arg1, DB_C_NUMERIC arg2, DB_C_NUMERIC answer, DB_C_NUMERIC remainder)
 
static int numeric_compare (DB_C_NUMERIC arg1, DB_C_NUMERIC arg2)
 
static int numeric_scale_by_ten (DB_C_NUMERIC arg, bool is_long_num)
 
static int numeric_scale_dec (const DB_C_NUMERIC arg, int dscale, DB_C_NUMERIC answer)
 
static int numeric_scale_dec_long (DB_C_NUMERIC answer, int dscale, bool is_long_num)
 
static int numeric_common_prec_scale (const DB_VALUE *dbv1, const DB_VALUE *dbv2, DB_VALUE *dbv1_common, DB_VALUE *dbv2_common)
 
static int numeric_prec_scale_when_overflow (const DB_VALUE *dbv1, const DB_VALUE *dbv2, DB_VALUE *dbv1_common, DB_VALUE *dbv2_common)
 
static void numeric_coerce_big_num_to_dec_str (unsigned char *num, char *dec_str)
 
static int numeric_get_msb_for_dec (int src_prec, int src_scale, unsigned char *src, int *dest_prec, int *dest_scale, DB_C_NUMERIC dest)
 
static int numeric_fast_convert (double adouble, int dst_scale, DB_C_NUMERIC num, int *prec, int *scale)
 
static FP_VALUE_TYPE get_fp_value_type (double d)
 
static int numeric_internal_real_to_num (double adouble, int dst_scale, DB_C_NUMERIC num, int *prec, int *scale, bool is_float)
 
static void numeric_get_integral_part (const DB_C_NUMERIC num, const int src_prec, const int src_scale, const int dst_prec, DB_C_NUMERIC dest)
 
static void numeric_get_fractional_part (const DB_C_NUMERIC num, const int src_scale, const int dst_prec, DB_C_NUMERIC dest)
 
static bool numeric_is_fraction_part_zero (const DB_C_NUMERIC num, const int scale)
 
static bool numeric_is_longnum_value (DB_C_NUMERIC arg)
 
static int numeric_longnum_to_shortnum (DB_C_NUMERIC answer, DB_C_NUMERIC long_arg)
 
static void numeric_shortnum_to_longnum (DB_C_NUMERIC long_answer, DB_C_NUMERIC arg)
 
static int get_significant_digit (DB_BIGINT i)
 
static void numeric_negative_one (DB_C_NUMERIC answer, int size)
 
int numeric_db_value_add (const DB_VALUE *dbv1, const DB_VALUE *dbv2, DB_VALUE *answer)
 
int numeric_db_value_sub (const DB_VALUE *dbv1, const DB_VALUE *dbv2, DB_VALUE *answer)
 
int numeric_db_value_mul (const DB_VALUE *dbv1, const DB_VALUE *dbv2, DB_VALUE *answer)
 
int numeric_db_value_div (const DB_VALUE *dbv1, const DB_VALUE *dbv2, DB_VALUE *answer)
 
int numeric_db_value_negate (DB_VALUE *answer)
 
void numeric_db_value_abs (DB_C_NUMERIC src_num, DB_C_NUMERIC dest_num)
 
int numeric_db_value_is_positive (const DB_VALUE *dbvalue)
 
int numeric_db_value_compare (const DB_VALUE *dbv1, const DB_VALUE *dbv2, DB_VALUE *answer)
 
void numeric_coerce_int_to_num (int arg, DB_C_NUMERIC answer)
 
void numeric_coerce_bigint_to_num (DB_BIGINT arg, DB_C_NUMERIC answer)
 
void numeric_coerce_num_to_int (DB_C_NUMERIC arg, int *answer)
 
int numeric_coerce_num_to_bigint (DB_C_NUMERIC arg, int scale, DB_BIGINT *answer)
 
void numeric_coerce_dec_str_to_num (const char *dec_str, DB_C_NUMERIC result)
 
void numeric_coerce_num_to_dec_str (DB_C_NUMERIC num, char *dec_str)
 
void numeric_coerce_num_to_double (DB_C_NUMERIC num, int scale, double *adouble)
 
int numeric_internal_double_to_num (double adouble, int dst_scale, DB_C_NUMERIC num, int *prec, int *scale)
 
int numeric_internal_float_to_num (float afloat, int dst_scale, DB_C_NUMERIC num, int *prec, int *scale)
 
int numeric_coerce_string_to_num (const char *astring, int astring_length, INTL_CODESET codeset, DB_VALUE *result)
 
int numeric_coerce_num_to_num (DB_C_NUMERIC src_num, int src_prec, int src_scale, int dest_prec, int dest_scale, DB_C_NUMERIC dest_num)
 
int numeric_db_value_coerce_to_num (DB_VALUE *src, DB_VALUE *dest, DB_DATA_STATUS *data_status)
 
int numeric_db_value_coerce_from_num (DB_VALUE *src, DB_VALUE *dest, DB_DATA_STATUS *data_status)
 
int numeric_db_value_coerce_from_num_strict (DB_VALUE *src, DB_VALUE *dest)
 
char * numeric_db_value_print (const DB_VALUE *val, char *buf)
 
bool numeric_db_value_is_zero (const DB_VALUE *arg)
 
int numeric_db_value_increase (DB_VALUE *arg)
 

Variables

static const char fast_mod [20]
 
static DEC_STRING powers_of_2 [DB_NUMERIC_BUF_SIZE *16]
 
static bool initialized_2 = false
 
static unsigned char powers_of_10 [TWICE_NUM_MAX_PREC+1][DB_NUMERIC_BUF_SIZE]
 
static bool initialized_10 = false
 
static double numeric_Pow_of_10 [10]
 

Macro Definition Documentation

#define CARRYOVER (   arg)    ((arg) >> 8)

Definition at line 58 of file numeric_opfunc.c.

Referenced by numeric_add(), numeric_mul(), and numeric_scale_by_ten().

#define GET_LOWER_BYTE (   arg)    ((arg) & 0xff)

Definition at line 59 of file numeric_opfunc.c.

Referenced by numeric_add(), numeric_mul(), and numeric_scale_by_ten().

#define NUMERIC_ABS (   a)    ((a) >= 0 ? a : -a)

Definition at line 60 of file numeric_opfunc.c.

Referenced by numeric_internal_real_to_num().

#define ROUND (   x)    ((x) > 0 ? ((x) + .5) : ((x) - .5))
#define SECONDS_IN_A_DAY   (int)(24L * 60L * 60L)

Definition at line 62 of file numeric_opfunc.c.

Referenced by numeric_db_value_coerce_from_num().

Typedef Documentation

typedef struct dec_string DEC_STRING

Definition at line 66 of file numeric_opfunc.c.

Enumeration Type Documentation

Enumerator
FP_VALUE_TYPE_NUMBER 
FP_VALUE_TYPE_INFINITE 
FP_VALUE_TYPE_NAN 
FP_VALUE_TYPE_ZERO 

Definition at line 89 of file numeric_opfunc.c.

Function Documentation

FP_VALUE_TYPE get_fp_value_type ( double  d)
static

Definition at line 2817 of file numeric_opfunc.c.

References FP_VALUE_TYPE_INFINITE, FP_VALUE_TYPE_NAN, FP_VALUE_TYPE_NUMBER, and FP_VALUE_TYPE_ZERO.

Referenced by numeric_internal_real_to_num().

Here is the caller graph for this function:

static int get_significant_digit ( DB_BIGINT  i)
static

Definition at line 3358 of file numeric_opfunc.c.

Referenced by numeric_db_value_coerce_to_num().

Here is the caller graph for this function:

static void numeric_add ( DB_C_NUMERIC  arg1,
DB_C_NUMERIC  arg2,
DB_C_NUMERIC  answer,
int  size 
)
static
static void numeric_add_dec_str ( DEC_STRING arg1,
DEC_STRING arg2,
DEC_STRING answer 
)
static

Definition at line 334 of file numeric_opfunc.c.

References assert, dec_string::digits, fast_mod, and TWICE_NUM_MAX_PREC.

Referenced by numeric_coerce_big_num_to_dec_str(), numeric_coerce_num_to_dec_str(), and numeric_init_pow_of_2_helper().

Here is the caller graph for this function:

static void numeric_coerce_big_num_to_dec_str ( unsigned char *  num,
char *  dec_str 
)
static
void numeric_coerce_bigint_to_num ( DB_BIGINT  arg,
DB_C_NUMERIC  answer 
)

Definition at line 2276 of file numeric_opfunc.c.

References DB_NUMERIC_BUF_SIZE.

Referenced by numeric_db_value_coerce_to_num(), and numeric_div().

Here is the caller graph for this function:

void numeric_coerce_int_to_num ( int  arg,
DB_C_NUMERIC  answer 
)

Definition at line 2245 of file numeric_opfunc.c.

References DB_NUMERIC_BUF_SIZE.

Referenced by boot_define_serial(), numeric_coerce_dec_str_to_num(), numeric_db_value_coerce_to_num(), numeric_div(), numeric_long_div(), and serial_get_nth_value().

Here is the caller graph for this function:

void numeric_coerce_num_to_int ( DB_C_NUMERIC  arg,
int *  answer 
)

Definition at line 2311 of file numeric_opfunc.c.

References DB_NUMERIC_BUF_SIZE, and numeric_is_negative().

Referenced by numeric_div().

Here is the caller graph for this function:

int numeric_coerce_num_to_num ( DB_C_NUMERIC  src_num,
int  src_prec,
int  src_scale,
int  dest_prec,
int  dest_scale,
DB_C_NUMERIC  dest_num 
)
static int numeric_compare ( DB_C_NUMERIC  arg1,
DB_C_NUMERIC  arg2 
)
static

Definition at line 1205 of file numeric_opfunc.c.

References DB_NUMERIC_BUF_SIZE, numeric_compare_pos(), numeric_copy(), numeric_is_negative(), and numeric_negate().

Referenced by numeric_db_value_compare(), and numeric_db_value_div().

Here is the caller graph for this function:

static int numeric_compare_pos ( DB_C_NUMERIC  arg1,
DB_C_NUMERIC  arg2 
)
static

Definition at line 573 of file numeric_opfunc.c.

References DB_NUMERIC_BUF_SIZE.

Referenced by numeric_compare(), numeric_long_div(), and numeric_overflow().

Here is the caller graph for this function:

static void numeric_copy_long ( DB_C_NUMERIC  dest,
DB_C_NUMERIC  source,
bool  is_long_num 
)
static

Definition at line 191 of file numeric_opfunc.c.

References assert, DB_LONG_NUMERIC_MULTIPLIER, DB_NUMERIC_BUF_SIZE, and NULL.

Referenced by numeric_copy(), numeric_double_shift_bit(), and numeric_long_div().

Here is the caller graph for this function:

void numeric_db_value_abs ( DB_C_NUMERIC  src_num,
DB_C_NUMERIC  dest_num 
)

Definition at line 2074 of file numeric_opfunc.c.

References numeric_copy(), numeric_is_negative(), and numeric_negate().

Referenced by db_abs_dbval().

Here is the caller graph for this function:

int numeric_db_value_coerce_from_num ( DB_VALUE src,
DB_VALUE dest,
DB_DATA_STATUS data_status 
)
int numeric_db_value_increase ( DB_VALUE arg)
int numeric_db_value_is_positive ( const DB_VALUE dbvalue)

Definition at line 2089 of file numeric_opfunc.c.

References DB_IS_NULL, db_locate_numeric, DB_TYPE_NUMERIC, DB_VALUE_TYPE, ER_OBJ_INVALID_ARGUMENTS, NULL, and numeric_is_negative().

Referenced by heap_object_upgrade_domain(), and serial_get_nth_value().

Here is the caller graph for this function:

bool numeric_db_value_is_zero ( const DB_VALUE arg)

Definition at line 3916 of file numeric_opfunc.c.

References db_get_numeric(), DB_IS_NULL, and numeric_is_zero().

Referenced by pt_evaluate_db_value_expr(), and qdata_is_divided_zero().

Here is the caller graph for this function:

int numeric_db_value_negate ( DB_VALUE answer)

Definition at line 2047 of file numeric_opfunc.c.

References DB_IS_NULL, db_locate_numeric, DB_TYPE_NUMERIC, DB_VALUE_TYPE, ER_OBJ_INVALID_ARGUMENTS, NO_ERROR, NULL, and numeric_negate().

Referenced by pt_evaluate_db_value_expr(), and qdata_unary_minus_dbval().

Here is the caller graph for this function:

static void numeric_decrease ( DB_C_NUMERIC  answer)
static

Definition at line 262 of file numeric_opfunc.c.

References DB_NUMERIC_BUF_SIZE.

Referenced by numeric_coerce_num_to_bigint(), and numeric_db_value_div().

Here is the caller graph for this function:

static void numeric_div ( DB_C_NUMERIC  arg1,
DB_C_NUMERIC  arg2,
DB_C_NUMERIC  answer,
DB_C_NUMERIC  remainder 
)
static
static void numeric_double_shift_bit ( DB_C_NUMERIC  arg1,
DB_C_NUMERIC  arg2,
int  numbits,
DB_C_NUMERIC  lsb,
DB_C_NUMERIC  msb,
bool  is_long_num 
)
static

Definition at line 519 of file numeric_opfunc.c.

References DB_LONG_NUMERIC_MULTIPLIER, DB_NUMERIC_BUF_SIZE, numeric_copy(), and numeric_copy_long().

Referenced by numeric_long_div().

Here is the caller graph for this function:

static int numeric_fast_convert ( double  adouble,
int  dst_scale,
DB_C_NUMERIC  num,
int *  prec,
int *  scale 
)
static
static void numeric_get_fractional_part ( const DB_C_NUMERIC  num,
const int  src_scale,
const int  dst_prec,
DB_C_NUMERIC  dest 
)
static
static void numeric_get_integral_part ( const DB_C_NUMERIC  num,
const int  src_prec,
const int  src_scale,
const int  dst_prec,
DB_C_NUMERIC  dest 
)
static
static int numeric_get_msb_for_dec ( int  src_prec,
int  src_scale,
unsigned char *  src,
int *  dest_prec,
int *  dest_scale,
DB_C_NUMERIC  dest 
)
static
static DB_C_NUMERIC numeric_get_pow_of_10 ( int  exp)
static

Definition at line 474 of file numeric_opfunc.c.

References assert, initialized_10, numeric_init_pow_of_10_helper(), and powers_of_10.

Referenced by numeric_coerce_num_to_bigint(), and numeric_overflow().

Here is the caller graph for this function:

static DEC_STRING * numeric_get_pow_of_2 ( int  exp)
static

Definition at line 415 of file numeric_opfunc.c.

References assert, DB_NUMERIC_BUF_SIZE, initialized_2, and numeric_init_pow_of_2_helper().

Referenced by numeric_coerce_big_num_to_dec_str(), and numeric_coerce_num_to_dec_str().

Here is the caller graph for this function:

static void numeric_increase ( DB_C_NUMERIC  answer)
static

Definition at line 219 of file numeric_opfunc.c.

References numeric_increase_long().

Referenced by numeric_coerce_num_to_bigint(), numeric_coerce_num_to_num(), numeric_db_value_div(), and numeric_db_value_increase().

Here is the caller graph for this function:

static void numeric_increase_long ( DB_C_NUMERIC  answer,
bool  is_long_num 
)
static

Definition at line 233 of file numeric_opfunc.c.

References DB_LONG_NUMERIC_MULTIPLIER, and DB_NUMERIC_BUF_SIZE.

Referenced by numeric_increase(), and numeric_negate_long().

Here is the caller graph for this function:

static void numeric_init_dec_str ( DEC_STRING answer)
static

Definition at line 314 of file numeric_opfunc.c.

References dec_string::digits, and TWICE_NUM_MAX_PREC.

Referenced by numeric_coerce_big_num_to_dec_str(), numeric_coerce_num_to_dec_str(), and numeric_init_pow_of_2_helper().

Here is the caller graph for this function:

static void numeric_init_pow_of_10_helper ( void  )
static

Definition at line 437 of file numeric_opfunc.c.

References DB_NUMERIC_BUF_SIZE, i, numeric_scale_dec(), numeric_zero(), powers_of_10, and TWICE_NUM_MAX_PREC.

Referenced by numeric_get_pow_of_10().

Here is the caller graph for this function:

static void numeric_init_pow_of_2_helper ( void  )
static

Definition at line 377 of file numeric_opfunc.c.

References DB_NUMERIC_BUF_SIZE, dec_string::digits, i, numeric_add_dec_str(), numeric_init_dec_str(), and TWICE_NUM_MAX_PREC.

Referenced by numeric_get_pow_of_2().

Here is the caller graph for this function:

int numeric_internal_double_to_num ( double  adouble,
int  dst_scale,
DB_C_NUMERIC  num,
int *  prec,
int *  scale 
)

Definition at line 2786 of file numeric_opfunc.c.

References numeric_internal_real_to_num().

Referenced by db_mod_bigint(), db_mod_int(), db_mod_numeric(), db_mod_short(), numeric_db_value_coerce_to_num(), and numeric_internal_real_to_num().

Here is the caller graph for this function:

int numeric_internal_float_to_num ( float  afloat,
int  dst_scale,
DB_C_NUMERIC  num,
int *  prec,
int *  scale 
)

Definition at line 2804 of file numeric_opfunc.c.

References numeric_internal_real_to_num().

Referenced by numeric_db_value_coerce_to_num().

Here is the caller graph for this function:

static bool numeric_is_bigint ( DB_C_NUMERIC  arg)
static

Definition at line 742 of file numeric_opfunc.c.

References DB_NUMERIC_BUF_SIZE.

Referenced by numeric_coerce_num_to_bigint(), and numeric_div().

Here is the caller graph for this function:

static bool numeric_is_bit_set ( DB_C_NUMERIC  arg,
int  pos 
)
static

Definition at line 778 of file numeric_opfunc.c.

Referenced by numeric_coerce_big_num_to_dec_str(), and numeric_coerce_num_to_dec_str().

Here is the caller graph for this function:

static bool numeric_is_fraction_part_zero ( const DB_C_NUMERIC  num,
const int  scale 
)
static

Definition at line 2760 of file numeric_opfunc.c.

References DB_MAX_NUMERIC_PRECISION, i, numeric_coerce_num_to_dec_str(), and strlen.

Referenced by numeric_db_value_coerce_from_num_strict().

Here is the caller graph for this function:

static bool numeric_is_long ( DB_C_NUMERIC  arg)
static

Definition at line 707 of file numeric_opfunc.c.

References DB_NUMERIC_BUF_SIZE.

Referenced by numeric_div().

Here is the caller graph for this function:

static bool numeric_is_longnum_value ( DB_C_NUMERIC  arg)
static

Definition at line 1100 of file numeric_opfunc.c.

References DB_LONG_NUMERIC_MULTIPLIER, DB_NUMERIC_BUF_SIZE, i, and numeric_is_negative().

Referenced by numeric_db_value_div(), and numeric_longnum_to_shortnum().

Here is the caller graph for this function:

static bool numeric_is_zero ( DB_C_NUMERIC  arg)
static

Definition at line 683 of file numeric_opfunc.c.

References DB_NUMERIC_BUF_SIZE.

Referenced by numeric_coerce_num_to_bigint(), numeric_db_value_is_zero(), numeric_div(), numeric_get_msb_for_dec(), and numeric_mul().

Here is the caller graph for this function:

static void numeric_long_div ( DB_C_NUMERIC  a1,
DB_C_NUMERIC  a2,
DB_C_NUMERIC  answer,
DB_C_NUMERIC  remainder,
bool  is_long_num 
)
static
static int numeric_longnum_to_shortnum ( DB_C_NUMERIC  answer,
DB_C_NUMERIC  long_arg 
)
static

Definition at line 1181 of file numeric_opfunc.c.

References DB_LONG_NUMERIC_MULTIPLIER, DB_NUMERIC_BUF_SIZE, ER_IT_DATA_OVERFLOW, NO_ERROR, numeric_copy(), and numeric_is_longnum_value().

Referenced by numeric_db_value_div().

Here is the caller graph for this function:

static void numeric_mul ( DB_C_NUMERIC  a1,
DB_C_NUMERIC  a2,
bool positive_flag,
DB_C_NUMERIC  answer 
)
static
static void numeric_negate_long ( DB_C_NUMERIC  answer,
bool  is_long_num 
)
static

Definition at line 614 of file numeric_opfunc.c.

References DB_LONG_NUMERIC_MULTIPLIER, DB_NUMERIC_BUF_SIZE, and numeric_increase_long().

Referenced by numeric_long_div(), numeric_negate(), and numeric_scale_by_ten().

Here is the caller graph for this function:

static void numeric_negative_one ( DB_C_NUMERIC  answer,
int  size 
)
static

Definition at line 298 of file numeric_opfunc.c.

Referenced by numeric_shortnum_to_longnum().

Here is the caller graph for this function:

static bool numeric_overflow ( DB_C_NUMERIC  arg,
int  exp 
)
static
static int numeric_prec_scale_when_overflow ( const DB_VALUE dbv1,
const DB_VALUE dbv2,
DB_VALUE dbv1_common,
DB_VALUE dbv2_common 
)
static
static int numeric_scale_by_ten ( DB_C_NUMERIC  arg,
bool  is_long_num 
)
static

Definition at line 1248 of file numeric_opfunc.c.

References CARRYOVER, DB_LONG_NUMERIC_MULTIPLIER, DB_NUMERIC_BUF_SIZE, ER_IT_DATA_OVERFLOW, GET_LOWER_BYTE, i, NO_ERROR, numeric_is_negative(), and numeric_negate_long().

Referenced by numeric_scale_dec_long().

Here is the caller graph for this function:

static int numeric_scale_dec ( const DB_C_NUMERIC  arg,
int  dscale,
DB_C_NUMERIC  answer 
)
static

Definition at line 1298 of file numeric_opfunc.c.

References NO_ERROR, numeric_copy(), and numeric_scale_dec_long().

Referenced by numeric_coerce_dec_str_to_num(), numeric_common_prec_scale(), and numeric_init_pow_of_10_helper().

Here is the caller graph for this function:

static int numeric_scale_dec_long ( DB_C_NUMERIC  answer,
int  dscale,
bool  is_long_num 
)
static

Definition at line 1322 of file numeric_opfunc.c.

References NO_ERROR, and numeric_scale_by_ten().

Referenced by numeric_db_value_div(), and numeric_scale_dec().

Here is the caller graph for this function:

static void numeric_shift_byte ( DB_C_NUMERIC  arg,
int  numbytes,
DB_C_NUMERIC  answer,
int  length 
)
static

Definition at line 650 of file numeric_opfunc.c.

References DB_NUMERIC_BUF_SIZE.

Referenced by numeric_mul().

Here is the caller graph for this function:

static void numeric_shortnum_to_longnum ( DB_C_NUMERIC  long_answer,
DB_C_NUMERIC  arg 
)
static

Definition at line 1150 of file numeric_opfunc.c.

References DB_LONG_NUMERIC_MULTIPLIER, DB_NUMERIC_BUF_SIZE, i, numeric_copy(), numeric_is_negative(), numeric_negative_one(), and numeric_zero().

Referenced by numeric_db_value_div().

Here is the caller graph for this function:

static void numeric_sub ( DB_C_NUMERIC  arg1,
DB_C_NUMERIC  arg2,
DB_C_NUMERIC  answer,
int  size 
)
static

Definition at line 845 of file numeric_opfunc.c.

References DB_NUMERIC_BUF_SIZE, numeric_add(), numeric_copy(), and numeric_negate().

Referenced by numeric_db_value_sub().

Here is the caller graph for this function:

static void numeric_zero ( DB_C_NUMERIC  answer,
int  size 
)
static

Variable Documentation

const char fast_mod[20]
static
Initial value:
= { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9,
0, 1, 2, 3, 4, 5, 6, 7, 8, 9
}

Definition at line 72 of file numeric_opfunc.c.

Referenced by numeric_add_dec_str().

bool initialized_10 = false
static

Definition at line 82 of file numeric_opfunc.c.

Referenced by numeric_get_pow_of_10().

bool initialized_2 = false
static

Definition at line 78 of file numeric_opfunc.c.

Referenced by numeric_get_pow_of_2().

double numeric_Pow_of_10[10]
static
Initial value:
= {
1e0, 1e1, 1e2, 1e3, 1e4, 1e5, 1e6, 1e7, 1e8, 1e9
}

Definition at line 85 of file numeric_opfunc.c.

Referenced by numeric_fast_convert().

unsigned char powers_of_10[TWICE_NUM_MAX_PREC+1][DB_NUMERIC_BUF_SIZE]
static
DEC_STRING powers_of_2[DB_NUMERIC_BUF_SIZE *16]
static

Definition at line 76 of file numeric_opfunc.c.