NCBI C++ ToolKit
Macros | Functions | Variables
numeric.c File Reference
#include <config.h>
#include <stdarg.h>
#include <stdio.h>
#include <freetds/tds.h>
#include <freetds/convert.h>
#include <freetds/bytes.h>
#include <stdlib.h>
#include "num_limits.h"
+ Include dependency graph for numeric.c:

Go to the source code of this file.

Go to the SVN repository for this file.

Macros

#define TDS_WORD   TDS_UINT
 
#define TDS_DWORD   TDS_UINT8
 
#define TDS_WORD_DDIGIT   9
 

Functions

 TDS_COMPILE_CHECK (maxprecision, MAXPRECISION< TDS_VECTOR_SIZE(tds_numeric_bytes_per_prec))
 
char * tds_money_to_string (const TDS_MONEY *money, char *s)
 
TDS_INT tds_numeric_to_string (const TDS_NUMERIC *numeric, char *s)
 
static int tds_packet_check_overflow (TDS_UINT *packet, unsigned int packet_len, unsigned int prec)
 
TDS_INT tds_numeric_change_prec_scale (TDS_NUMERIC *numeric, unsigned char new_prec, unsigned char new_scale)
 

Variables

const int tds_numeric_bytes_per_prec []
 tds_numeric_bytes_per_prec is indexed by precision and will tell us the number of bytes required to store the specified precision (with the sign). More...
 

Macro Definition Documentation

◆ TDS_DWORD

#define TDS_DWORD   TDS_UINT8

Definition at line 197 of file numeric.c.

◆ TDS_WORD

#define TDS_WORD   TDS_UINT

Definition at line 196 of file numeric.c.

◆ TDS_WORD_DDIGIT

#define TDS_WORD_DDIGIT   9

Definition at line 198 of file numeric.c.

Function Documentation

◆ TDS_COMPILE_CHECK()

TDS_COMPILE_CHECK ( maxprecision  )

◆ tds_money_to_string()

char* tds_money_to_string ( const TDS_MONEY money,
char *  s 
)

Definition at line 64 of file numeric.c.

References if(), int, tdsoldmoney::mnyhigh, tdsoldmoney::mnylow, n, PRId64, and tdsmoney::tdsoldmoney.

◆ tds_numeric_change_prec_scale()

TDS_INT tds_numeric_change_prec_scale ( TDS_NUMERIC numeric,
unsigned char  new_prec,
unsigned char  new_scale 
)

◆ tds_numeric_to_string()

TDS_INT tds_numeric_to_string ( const TDS_NUMERIC numeric,
char *  s 
)

◆ tds_packet_check_overflow()

static int tds_packet_check_overflow ( TDS_UINT packet,
unsigned int  packet_len,
unsigned int  prec 
)
static

Definition at line 205 of file numeric.c.

References i, len, limit_indexes, LIMIT_INDEXES_ADJUST, limits, TDS_CONVERT_OVERFLOW, and TDS_WORD.

Referenced by tds_numeric_change_prec_scale().

Variable Documentation

◆ tds_numeric_bytes_per_prec

const int tds_numeric_bytes_per_prec[]
Initial value:
= {
1,
2, 2, 3, 3, 4, 4, 4, 5, 5,
6, 6, 6, 7, 7, 8, 8, 9, 9, 9,
10, 10, 11, 11, 11, 12, 12, 13, 13, 14,
14, 14, 15, 15, 16, 16, 16, 17, 17, 18,
18, 19, 19, 19, 20, 20, 21, 21, 21, 22,
22, 23, 23, 24, 24, 24, 25, 25, 26, 26,
26, 27, 27, 28, 28, 28, 29, 29, 30, 30,
31, 31, 31, 32, 32, 33, 33, 33
}

tds_numeric_bytes_per_prec is indexed by precision and will tell us the number of bytes required to store the specified precision (with the sign).

The following little table is indexed by precision and will tell us the number of bytes required to store the specified precision.

Support precision up to 77 digits

Definition at line 41 of file numeric.c.

Referenced by tds_numeric_change_prec_scale(), and tds_numeric_to_string().

Modified on Fri Jun 14 16:53:52 2024 by modify_doxy.py rev. 669887