shared_func.h: add functions float2buff / buff2float, double2buff / buff2double
parent
5416c29a27
commit
7751ae2808
4
HISTORY
4
HISTORY
|
|
@ -1,4 +1,8 @@
|
||||||
|
|
||||||
|
Version 1.38 2018-05-10
|
||||||
|
* connection_pool.c: set err_no to 0 when success
|
||||||
|
* shared_func.h: add functions float2buff / buff2float, double2buff / buff2double
|
||||||
|
|
||||||
Version 1.37 2018-02-24
|
Version 1.37 2018-02-24
|
||||||
* ini_file_reader.c function annotations LOCAL_IP_GET support index, such as:
|
* ini_file_reader.c function annotations LOCAL_IP_GET support index, such as:
|
||||||
#@function LOCAL_IP_GET
|
#@function LOCAL_IP_GET
|
||||||
|
|
|
||||||
|
|
@ -192,6 +192,53 @@ void long2buff(int64_t n, char *buff);
|
||||||
*/
|
*/
|
||||||
int64_t buff2long(const char *buff);
|
int64_t buff2long(const char *buff);
|
||||||
|
|
||||||
|
|
||||||
|
/** 32 bits float convert to buffer (big-endian)
|
||||||
|
* parameters:
|
||||||
|
* n: 32 bits float value
|
||||||
|
* buff: the buffer, at least 4 bytes space, no tail \0
|
||||||
|
* return: none
|
||||||
|
*/
|
||||||
|
static inline void float2buff(float f, char *buff)
|
||||||
|
{
|
||||||
|
int2buff(*((int *)&f), buff);
|
||||||
|
}
|
||||||
|
|
||||||
|
/** buffer convert to 32 bits float
|
||||||
|
* parameters:
|
||||||
|
* buff: big-endian 8 bytes buffer
|
||||||
|
* return: 32 bits float value
|
||||||
|
*/
|
||||||
|
static inline float buff2float(const char *buff)
|
||||||
|
{
|
||||||
|
int n;
|
||||||
|
n = buff2int(buff);
|
||||||
|
return *((float *)&n);
|
||||||
|
}
|
||||||
|
|
||||||
|
/** double (64 bits) convert to buffer (big-endian)
|
||||||
|
* parameters:
|
||||||
|
* n: 64 bits double value
|
||||||
|
* buff: the buffer, at least 8 bytes space, no tail \0
|
||||||
|
* return: none
|
||||||
|
*/
|
||||||
|
static inline void double2buff(double d, char *buff)
|
||||||
|
{
|
||||||
|
long2buff(*((int64_t *)&d), buff);
|
||||||
|
}
|
||||||
|
|
||||||
|
/** buffer convert to 64 bits double
|
||||||
|
* parameters:
|
||||||
|
* buff: big-endian 8 bytes buffer
|
||||||
|
* return: 64 bits double value
|
||||||
|
*/
|
||||||
|
static inline double buff2double(const char *buff)
|
||||||
|
{
|
||||||
|
int64_t n;
|
||||||
|
n = buff2long(buff);
|
||||||
|
return *((double *)&n);
|
||||||
|
}
|
||||||
|
|
||||||
/** trim leading spaces ( \t\r\n)
|
/** trim leading spaces ( \t\r\n)
|
||||||
* parameters:
|
* parameters:
|
||||||
* pStr: the string to trim
|
* pStr: the string to trim
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue