File numeric_opfunc.c
FileList > cubrid > src > query > numeric_opfunc.c
Go to the source code of this file
#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 <cmath>
#include "dbtype.h"
#include "memory_wrapper.hpp"
Classes
Public Types
Public Static Attributes
Public Functions
| Type |
Name |
| void |
numeric_coerce_bigint_to_num (DB_BIGINT arg, DB_C_NUMERIC answer)
|
| void |
numeric_coerce_dec_str_to_num (const char * dec_str, DB_C_NUMERIC result)
|
| int |
numeric_coerce_double_to_num (double adouble, DB_C_NUMERIC num, int * prec, int * scale)
|
| void |
numeric_coerce_int_to_num (int arg, DB_C_NUMERIC answer)
|
| int |
numeric_coerce_num_to_bigint (DB_C_NUMERIC arg, int scale, DB_BIGINT * answer)
|
| 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)
|
| void |
numeric_coerce_num_to_int (DB_C_NUMERIC arg, int * answer)
|
| 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_coerce_string_to_num (const char * astring, int astring_length, INTL_CODESET codeset, DB_VALUE * result)
|
| void |
numeric_db_value_abs (DB_C_NUMERIC src_num, DB_C_NUMERIC dest_num)
|
| int |
numeric_db_value_add (const DB_VALUE * dbv1, const DB_VALUE * dbv2, DB_VALUE * answer)
|
| 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)
|
| int |
numeric_db_value_coerce_to_num (DB_VALUE * src, DB_VALUE * dest, DB_DATA_STATUS * data_status)
|
| int |
numeric_db_value_compare (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_increase (DB_VALUE * arg)
|
| int |
numeric_db_value_is_positive (const DB_VALUE * dbvalue)
|
| bool |
numeric_db_value_is_zero (const DB_VALUE * arg)
|
| int |
numeric_db_value_mul (const DB_VALUE * dbv1, const DB_VALUE * dbv2, DB_VALUE * answer)
|
| int |
numeric_db_value_negate (DB_VALUE * answer)
|
| char * |
numeric_db_value_print (const DB_VALUE * val, char * buf)
|
| int |
numeric_db_value_sub (const DB_VALUE * dbv1, const DB_VALUE * dbv2, DB_VALUE * answer)
|
| void |
numeric_init_power_value_string (void)
|
| 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)
|
Public Static Functions
| Type |
Name |
| FP_VALUE_TYPE |
get_fp_value_type (double d)
|
| int |
get_significant_digit (DB_BIGINT i)
|
| void |
numeric_add (DB_C_NUMERIC arg1, DB_C_NUMERIC arg2, DB_C_NUMERIC answer, int size)
|
| void |
numeric_add_dec_str (DEC_STRING * arg1, DEC_STRING * arg2, DEC_STRING * answer)
|
| void |
numeric_coerce_big_num_to_dec_str (unsigned char * num, char * dec_str)
|
| int |
numeric_common_prec_scale (const DB_VALUE * dbv1, const DB_VALUE * dbv2, DB_VALUE * dbv1_common, DB_VALUE * dbv2_common)
|
| int |
numeric_compare (DB_C_NUMERIC arg1, DB_C_NUMERIC arg2)
|
| int |
numeric_compare_pos (DB_C_NUMERIC arg1, DB_C_NUMERIC arg2)
|
| void |
numeric_copy (DB_C_NUMERIC dest, DB_C_NUMERIC source)
|
| void |
numeric_copy_long (DB_C_NUMERIC dest, DB_C_NUMERIC source, bool is_long_num)
|
| void |
numeric_decrease (DB_C_NUMERIC answer)
|
| void |
numeric_div (DB_C_NUMERIC arg1, DB_C_NUMERIC arg2, DB_C_NUMERIC answer, DB_C_NUMERIC remainder)
|
| 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)
|
| int |
numeric_fast_convert (double adouble, int dst_scale, DB_C_NUMERIC num, int * prec, int * scale)
|
| void |
numeric_get_fractional_part (const DB_C_NUMERIC num, const int src_scale, const int dst_prec, DB_C_NUMERIC dest)
|
| 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)
|
| 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)
|
| DB_C_NUMERIC |
numeric_get_pow_of_10 (int exp)
|
| DEC_STRING * |
numeric_get_pow_of_2 (int exp)
|
| void |
numeric_increase (DB_C_NUMERIC answer)
|
| void |
numeric_increase_long (DB_C_NUMERIC answer, bool is_long_num)
|
| void |
numeric_init_dec_str (DEC_STRING * answer)
|
| void |
numeric_init_pow_of_10 (void)
|
| void |
numeric_init_pow_of_10_helper (void)
|
| void |
numeric_init_pow_of_2 (void)
|
| void |
numeric_init_pow_of_2_helper (void)
|
| int |
numeric_internal_real_to_num (double adouble, int dst_scale, DB_C_NUMERIC num, int * prec, int * scale, bool is_float)
|
| bool |
numeric_is_bigint (DB_C_NUMERIC arg)
|
| bool |
numeric_is_bit_set (DB_C_NUMERIC arg, int pos)
|
| bool |
numeric_is_fraction_part_zero (const DB_C_NUMERIC num, const int scale)
|
| bool |
numeric_is_long (DB_C_NUMERIC arg)
|
| bool |
numeric_is_longnum_value (DB_C_NUMERIC arg)
|
| bool |
numeric_is_negative (DB_C_NUMERIC arg)
|
| bool |
numeric_is_zero (DB_C_NUMERIC arg)
|
| void |
numeric_long_div (DB_C_NUMERIC a1, DB_C_NUMERIC a2, DB_C_NUMERIC answer, DB_C_NUMERIC remainder, bool is_long_num)
|
| int |
numeric_longnum_to_shortnum (DB_C_NUMERIC answer, DB_C_NUMERIC long_arg)
|
| void |
numeric_mul (DB_C_NUMERIC a1, DB_C_NUMERIC a2, bool * positive_flag, DB_C_NUMERIC answer)
|
| void |
numeric_negate (DB_C_NUMERIC answer)
|
| void |
numeric_negate_long (DB_C_NUMERIC answer, bool is_long_num)
|
| void |
numeric_negative_one (DB_C_NUMERIC answer, int size)
|
| bool |
numeric_overflow (DB_C_NUMERIC arg, int exp)
|
| int |
numeric_prec_scale_when_overflow (const DB_VALUE * dbv1, const DB_VALUE * dbv2, DB_VALUE * dbv1_common, DB_VALUE * dbv2_common)
|
| int |
numeric_scale_by_ten (DB_C_NUMERIC arg, bool is_long_num)
|
| int |
numeric_scale_dec (const DB_C_NUMERIC arg, int dscale, DB_C_NUMERIC answer)
|
| int |
numeric_scale_dec_long (DB_C_NUMERIC answer, int dscale, bool is_long_num)
|
| void |
numeric_shift_byte (DB_C_NUMERIC arg, int numbytes, DB_C_NUMERIC answer, int length)
|
| void |
numeric_shortnum_to_longnum (DB_C_NUMERIC long_answer, DB_C_NUMERIC arg)
|
| void |
numeric_sub (DB_C_NUMERIC arg1, DB_C_NUMERIC arg2, DB_C_NUMERIC answer, int size)
|
| void |
numeric_zero (DB_C_NUMERIC answer, int size)
|
Macros
| Type |
Name |
| define |
CARRYOVER (arg) ((arg) >> 8)
|
| define |
DB_LONG_NUMERIC_MULTIPLIER 2
|
| define |
GET_LOWER_BYTE (arg) ((arg) & 0xff)
|
| define |
NUMERIC_ABS (a) (([**a**](broker__monitor_8c.md#function-timeout)) >= 0 ? [**a**](broker__monitor_8c.md#function-timeout) : -[**a**](broker__monitor_8c.md#function-timeout))
|
| define |
ROUND (x) (([**x**](broker__monitor_8c.md#function-timeout)) > 0 ? (([**x**](broker__monitor_8c.md#function-timeout)) + .5) : (([**x**](broker__monitor_8c.md#function-timeout)) - .5))
|
| define |
SECONDS_IN_A_DAY ([**int**](broker__monitor_8c.md#function-timeout))(24[**L**](broker__monitor_8c.md#function-timeout) \* 60L \* 60L)
|
| define |
TWICE_NUM_MAX_PREC (2\*[**DB\_MAX\_NUMERIC\_PRECISION**](dbtype__def_8h.md#define-db_max_numeric_precision))
|
Public Types Documentation
typedef DEC_STRING
typedef struct dec_string DEC_STRING;
typedef FP_VALUE_TYPE
typedef enum fp_value_type FP_VALUE_TYPE;
enum fp_value_type
enum fp_value_type {
FP_VALUE_TYPE_NUMBER,
FP_VALUE_TYPE_INFINITE,
FP_VALUE_TYPE_NAN,
FP_VALUE_TYPE_ZERO
};
Public Static Attributes Documentation
variable fast_mod
variable numeric_Pow_of_10
const double numeric_Pow_of_10[10];
variable powers_of_10
unsigned char powers_of_10[(2 *DB_MAX_NUMERIC_PRECISION)+1][DB_NUMERIC_BUF_SIZE];
variable powers_of_2
DEC_STRING powers_of_2[DB_NUMERIC_BUF_SIZE *16];
Public Functions Documentation
function numeric_coerce_bigint_to_num
void numeric_coerce_bigint_to_num (
DB_BIGINT arg,
DB_C_NUMERIC answer
)
function numeric_coerce_dec_str_to_num
void numeric_coerce_dec_str_to_num (
const char * dec_str,
DB_C_NUMERIC result
)
function numeric_coerce_double_to_num
int numeric_coerce_double_to_num (
double adouble,
DB_C_NUMERIC num,
int * prec,
int * scale
)
function numeric_coerce_int_to_num
void numeric_coerce_int_to_num (
int arg,
DB_C_NUMERIC answer
)
function numeric_coerce_num_to_bigint
int numeric_coerce_num_to_bigint (
DB_C_NUMERIC arg,
int scale,
DB_BIGINT * answer
)
function numeric_coerce_num_to_dec_str
void numeric_coerce_num_to_dec_str (
DB_C_NUMERIC num,
char * dec_str
)
function numeric_coerce_num_to_double
void numeric_coerce_num_to_double (
DB_C_NUMERIC num,
int scale,
double * adouble
)
function numeric_coerce_num_to_int
void numeric_coerce_num_to_int (
DB_C_NUMERIC arg,
int * answer
)
function numeric_coerce_num_to_num
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
)
function numeric_coerce_string_to_num
int numeric_coerce_string_to_num (
const char * astring,
int astring_length,
INTL_CODESET codeset,
DB_VALUE * result
)
function numeric_db_value_abs
void numeric_db_value_abs (
DB_C_NUMERIC src_num,
DB_C_NUMERIC dest_num
)
function numeric_db_value_add
int numeric_db_value_add (
const DB_VALUE * dbv1,
const DB_VALUE * dbv2,
DB_VALUE * answer
)
function numeric_db_value_coerce_from_num
int numeric_db_value_coerce_from_num (
DB_VALUE * src,
DB_VALUE * dest,
DB_DATA_STATUS * data_status
)
function numeric_db_value_coerce_from_num_strict
int numeric_db_value_coerce_from_num_strict (
DB_VALUE * src,
DB_VALUE * dest
)
function numeric_db_value_coerce_to_num
int numeric_db_value_coerce_to_num (
DB_VALUE * src,
DB_VALUE * dest,
DB_DATA_STATUS * data_status
)
function numeric_db_value_compare
int numeric_db_value_compare (
const DB_VALUE * dbv1,
const DB_VALUE * dbv2,
DB_VALUE * answer
)
function numeric_db_value_div
int numeric_db_value_div (
const DB_VALUE * dbv1,
const DB_VALUE * dbv2,
DB_VALUE * answer
)
function numeric_db_value_increase
int numeric_db_value_increase (
DB_VALUE * arg
)
function numeric_db_value_is_positive
int numeric_db_value_is_positive (
const DB_VALUE * dbvalue
)
function numeric_db_value_is_zero
bool numeric_db_value_is_zero (
const DB_VALUE * arg
)
function numeric_db_value_mul
int numeric_db_value_mul (
const DB_VALUE * dbv1,
const DB_VALUE * dbv2,
DB_VALUE * answer
)
function numeric_db_value_negate
int numeric_db_value_negate (
DB_VALUE * answer
)
function numeric_db_value_print
char * numeric_db_value_print (
const DB_VALUE * val,
char * buf
)
function numeric_db_value_sub
int numeric_db_value_sub (
const DB_VALUE * dbv1,
const DB_VALUE * dbv2,
DB_VALUE * answer
)
function numeric_init_power_value_string
void numeric_init_power_value_string (
void
)
function numeric_internal_double_to_num
int numeric_internal_double_to_num (
double adouble,
int dst_scale,
DB_C_NUMERIC num,
int * prec,
int * scale
)
function numeric_internal_float_to_num
int numeric_internal_float_to_num (
float afloat,
int dst_scale,
DB_C_NUMERIC num,
int * prec,
int * scale
)
Public Static Functions Documentation
function get_fp_value_type
static FP_VALUE_TYPE get_fp_value_type (
double d
)
function get_significant_digit
static int get_significant_digit (
DB_BIGINT i
)
function numeric_add
static void numeric_add (
DB_C_NUMERIC arg1,
DB_C_NUMERIC arg2,
DB_C_NUMERIC answer,
int size
)
function numeric_add_dec_str
static void numeric_add_dec_str (
DEC_STRING * arg1,
DEC_STRING * arg2,
DEC_STRING * answer
)
function numeric_coerce_big_num_to_dec_str
static void numeric_coerce_big_num_to_dec_str (
unsigned char * num,
char * dec_str
)
function numeric_common_prec_scale
static int numeric_common_prec_scale (
const DB_VALUE * dbv1,
const DB_VALUE * dbv2,
DB_VALUE * dbv1_common,
DB_VALUE * dbv2_common
)
function numeric_compare
static int numeric_compare (
DB_C_NUMERIC arg1,
DB_C_NUMERIC arg2
)
function numeric_compare_pos
static int numeric_compare_pos (
DB_C_NUMERIC arg1,
DB_C_NUMERIC arg2
)
function numeric_copy
static void numeric_copy (
DB_C_NUMERIC dest,
DB_C_NUMERIC source
)
function numeric_copy_long
static void numeric_copy_long (
DB_C_NUMERIC dest,
DB_C_NUMERIC source,
bool is_long_num
)
function numeric_decrease
static void numeric_decrease (
DB_C_NUMERIC answer
)
function numeric_div
static void numeric_div (
DB_C_NUMERIC arg1,
DB_C_NUMERIC arg2,
DB_C_NUMERIC answer,
DB_C_NUMERIC remainder
)
function numeric_double_shift_bit
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
)
function numeric_fast_convert
static int numeric_fast_convert (
double adouble,
int dst_scale,
DB_C_NUMERIC num,
int * prec,
int * scale
)
function numeric_get_fractional_part
static void numeric_get_fractional_part (
const DB_C_NUMERIC num,
const int src_scale,
const int dst_prec,
DB_C_NUMERIC dest
)
function numeric_get_integral_part
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
)
function numeric_get_msb_for_dec
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
)
function numeric_get_pow_of_10
static DB_C_NUMERIC numeric_get_pow_of_10 (
int exp
)
function numeric_get_pow_of_2
static DEC_STRING * numeric_get_pow_of_2 (
int exp
)
function numeric_increase
static void numeric_increase (
DB_C_NUMERIC answer
)
function numeric_increase_long
static void numeric_increase_long (
DB_C_NUMERIC answer,
bool is_long_num
)
function numeric_init_dec_str
static void numeric_init_dec_str (
DEC_STRING * answer
)
function numeric_init_pow_of_10
static void numeric_init_pow_of_10 (
void
)
function numeric_init_pow_of_10_helper
static void numeric_init_pow_of_10_helper (
void
)
function numeric_init_pow_of_2
static void numeric_init_pow_of_2 (
void
)
function numeric_init_pow_of_2_helper
static void numeric_init_pow_of_2_helper (
void
)
function numeric_internal_real_to_num
static int numeric_internal_real_to_num (
double adouble,
int dst_scale,
DB_C_NUMERIC num,
int * prec,
int * scale,
bool is_float
)
function numeric_is_bigint
static bool numeric_is_bigint (
DB_C_NUMERIC arg
)
function numeric_is_bit_set
static bool numeric_is_bit_set (
DB_C_NUMERIC arg,
int pos
)
function numeric_is_fraction_part_zero
static bool numeric_is_fraction_part_zero (
const DB_C_NUMERIC num,
const int scale
)
function numeric_is_long
static bool numeric_is_long (
DB_C_NUMERIC arg
)
function numeric_is_longnum_value
static bool numeric_is_longnum_value (
DB_C_NUMERIC arg
)
function numeric_is_negative
static bool numeric_is_negative (
DB_C_NUMERIC arg
)
function numeric_is_zero
static bool numeric_is_zero (
DB_C_NUMERIC arg
)
function numeric_long_div
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
)
function numeric_longnum_to_shortnum
static int numeric_longnum_to_shortnum (
DB_C_NUMERIC answer,
DB_C_NUMERIC long_arg
)
function numeric_mul
static void numeric_mul (
DB_C_NUMERIC a1,
DB_C_NUMERIC a2,
bool * positive_flag,
DB_C_NUMERIC answer
)
function numeric_negate
static void numeric_negate (
DB_C_NUMERIC answer
)
function numeric_negate_long
static void numeric_negate_long (
DB_C_NUMERIC answer,
bool is_long_num
)
function numeric_negative_one
static void numeric_negative_one (
DB_C_NUMERIC answer,
int size
)
function numeric_overflow
static bool numeric_overflow (
DB_C_NUMERIC arg,
int exp
)
function numeric_prec_scale_when_overflow
static int numeric_prec_scale_when_overflow (
const DB_VALUE * dbv1,
const DB_VALUE * dbv2,
DB_VALUE * dbv1_common,
DB_VALUE * dbv2_common
)
function numeric_scale_by_ten
static int numeric_scale_by_ten (
DB_C_NUMERIC arg,
bool is_long_num
)
function numeric_scale_dec
static int numeric_scale_dec (
const DB_C_NUMERIC arg,
int dscale,
DB_C_NUMERIC answer
)
function numeric_scale_dec_long
static int numeric_scale_dec_long (
DB_C_NUMERIC answer,
int dscale,
bool is_long_num
)
function numeric_shift_byte
static void numeric_shift_byte (
DB_C_NUMERIC arg,
int numbytes,
DB_C_NUMERIC answer,
int length
)
function numeric_shortnum_to_longnum
static void numeric_shortnum_to_longnum (
DB_C_NUMERIC long_answer,
DB_C_NUMERIC arg
)
function numeric_sub
static void numeric_sub (
DB_C_NUMERIC arg1,
DB_C_NUMERIC arg2,
DB_C_NUMERIC answer,
int size
)
function numeric_zero
static void numeric_zero (
DB_C_NUMERIC answer,
int size
)
Macro Definition Documentation
define CARRYOVER
#define CARRYOVER (
arg
) `((arg) >> 8)`
define DB_LONG_NUMERIC_MULTIPLIER
#define DB_LONG_NUMERIC_MULTIPLIER `2`
define GET_LOWER_BYTE
#define GET_LOWER_BYTE (
arg
) `((arg) & 0xff)`
define NUMERIC_ABS
#define NUMERIC_ABS (
a
) `(( a ) >= 0 ? a : - a )`
define ROUND
#define ROUND (
x
) `(( x ) > 0 ? (( x ) + .5) : (( x ) - .5))`
define SECONDS_IN_A_DAY
#define SECONDS_IN_A_DAY `( int )(24 L * 60L * 60L)`
define TWICE_NUM_MAX_PREC
#define TWICE_NUM_MAX_PREC `(2* DB_MAX_NUMERIC_PRECISION )`
The documentation for this class was generated from the following file cubrid/src/query/numeric_opfunc.c