-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmodp_numtoa.h
59 lines (50 loc) · 1.48 KB
/
modp_numtoa.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
/**
* \file
*
* <pre>
* Copyright © 2007, Nick Galbreath -- nickg [at] modp [dot] com
* All rights reserved.
* http://code.google.com/p/stringencoders/
* Released under the bsd license.
* </pre>
*
* This defines signed/unsigned integer, and 'double' to char buffer
* converters. The standard way of doing this is with "sprintf", however
* these functions are
* * guarenteed maximum size output
* * 5-20x faster!
* * core-dump safe
*
*
*/
#ifndef COM_MODP_STRINGENCODERS_NUMTOA_H
#define COM_MODP_STRINGENCODERS_NUMTOA_H
#include <stdint.h>
namespace allyes {
namespace gmetric {
/** \brief convert an signed integer to char buffer
*
* \param[in] value
* \param[out] buf the output buffer. Should be 16 chars or more.
*/
void modp_itoa10(int32_t value, char* buf);
/** \brief convert an unsigned integer to char buffer
*
* \param[in] value
* \param[out] buf The output buffer, should be 16 chars or more.
*/
void modp_uitoa10(uint32_t value, char* buf);
/** \brief convert a floating point number to char buffer with fixed-precision format
*
* If the input value is greater than 1<<31, then the output format
* will be switched exponential format.
*
* \param[in] value
* \param[out] buf The allocated output buffer. Should be 32 chars or more.
* \param[in] precision Number of digits to the right of the decimal point.
* Can only be 0-9.
*/
void modp_dtoa(double value, char* buf, int precision);
} /* namespace gmetric */
} /* namespace allyes */
#endif