@@ -26,13 +26,13 @@ namespace fp_formatting {
26
26
*
27
27
* Example:
28
28
* std::array<char, 20> buffer;
29
- * auto ct = convertToChars (buffer.begin(), buffer.end(), 23, 3);
29
+ * auto ct = ConvertToChars (buffer.begin(), buffer.end(), 23, 3);
30
30
* assert(ct = 3);
31
31
* assert(buffer[0] == '0');
32
32
* assert(buffer[1] == '2');
33
33
* assert(buffer[2] == '3');
34
34
*/
35
- inline auto convertToChars (char * begin, char * end, size_t value, int width=1 ) -> int {
35
+ inline auto ConvertToChars (char * begin, char * end, size_t value, int width=1 ) -> int {
36
36
assert (width >= 1 );
37
37
assert (end >= begin); // end must be after begin
38
38
assert (end-begin >= width); // Buffer must be large enough
@@ -62,7 +62,7 @@ inline auto convertToChars(char* begin, char* end, size_t value, int width=1) ->
62
62
* converts a value 'v' to a string. Uses dragonbox for formatting.
63
63
*/
64
64
template <typename T>
65
- auto fp_to_string (T v, int precision = 0 ) -> std::string {
65
+ auto FpToString (T v, int precision = 0 ) -> std::string {
66
66
// assert(precision > 0);
67
67
// hardcoded constant, at which exponent should switch to a scientific notation
68
68
int const lowerExponentThreshold = -5 ;
@@ -81,7 +81,7 @@ auto fp_to_string(T v, int precision = 0) -> std::string {
81
81
auto r = jkj::dragonbox::to_decimal (v);
82
82
83
83
auto digits = std::array<char , 20 >{}; // max digits of size_t is 20.
84
- auto digits_ct = convertToChars (digits.data (), digits.data () + digits.size (), r.significand );
84
+ auto digits_ct = ConvertToChars (digits.data (), digits.data () + digits.size (), r.significand );
85
85
86
86
// check if requested precision is lower than
87
87
// required digits for exact representation
@@ -136,7 +136,7 @@ auto fp_to_string(T v, int precision = 0) -> std::string {
136
136
*(output_ptr++) = ' e' ;
137
137
*(output_ptr++) = (exponent>=0 )?' +' :' -' ;
138
138
auto exp_digits = std::array<char , 20 >{};
139
- auto exp_digits_ct = convertToChars (exp_digits.data (), exp_digits.data () + exp_digits.size (), std::abs (exponent), /* .precision=*/ 2 );
139
+ auto exp_digits_ct = ConvertToChars (exp_digits.data (), exp_digits.data () + exp_digits.size (), std::abs (exponent), /* .precision=*/ 2 );
140
140
for (int i{0 }; i < exp_digits_ct; ++i) {
141
141
*(output_ptr++) = exp_digits[i];
142
142
}
@@ -184,18 +184,18 @@ auto fp_to_string(T v, int precision = 0) -> std::string {
184
184
}
185
185
}
186
186
187
- inline auto fp_to_string (float v, size_t precision = 0 ) -> std::string {
188
- return detail::fp_formatting::fp_to_string (v, precision);
187
+ inline auto FpToString (float v, size_t precision = 0 ) -> std::string {
188
+ return detail::fp_formatting::FpToString (v, precision);
189
189
}
190
190
191
- inline auto fp_to_string (double v, size_t precision = 0 ) -> std::string {
192
- return detail::fp_formatting::fp_to_string (v, precision);
191
+ inline auto FpToString (double v, size_t precision = 0 ) -> std::string {
192
+ return detail::fp_formatting::FpToString (v, precision);
193
193
}
194
194
195
195
/* *
196
196
* dragonbox only works for floats/doubles not long double
197
197
*/
198
- inline auto fp_to_string (long double v, size_t precision = std::numeric_limits<long double >::max_digits10) -> std::string {
198
+ inline auto FpToString (long double v, size_t precision = std::numeric_limits<long double >::max_digits10) -> std::string {
199
199
std::stringstream ss;
200
200
ss.precision (precision);
201
201
ss.imbue (std::locale (" C" ));
0 commit comments