-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Mostly complete FakeOFStream. Copy fast integer to string routines.
- Loading branch information
Showing
9 changed files
with
856 additions
and
43 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
#include "util/float_to_string.hh" | ||
|
||
#include "util/double-conversion/double-conversion.h" | ||
#include "util/double-conversion/utils.h" | ||
|
||
namespace util { | ||
namespace { | ||
const double_conversion::DoubleToStringConverter kConverter(double_conversion::DoubleToStringConverter::NO_FLAGS, "inf", "NaN", 'e', -6, 21, 6, 0); | ||
} // namespace | ||
|
||
char *ToString(double value, char *to) { | ||
double_conversion::StringBuilder builder(to, ToStringBuf<double>::kBytes); | ||
kConverter.ToShortest(value, &builder); | ||
return &to[builder.position()]; | ||
} | ||
|
||
char *ToString(float value, char *to) { | ||
double_conversion::StringBuilder builder(to, ToStringBuf<float>::kBytes); | ||
kConverter.ToShortestSingle(value, &builder); | ||
return &to[builder.position()]; | ||
} | ||
|
||
} // namespace util |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
#ifndef UTIL_FLOAT_TO_STRING_H | ||
#define UTIL_FLOAT_TO_STRING_H | ||
|
||
// Just for ToStringBuf | ||
#include "util/integer_to_string.hh" | ||
|
||
namespace util { | ||
|
||
template <> struct ToStringBuf<double> { | ||
// DoubleToStringConverter::kBase10MaximalLength + 1 for null paranoia. | ||
static const unsigned kBytes = 18; | ||
}; | ||
|
||
// Single wasn't documented in double conversion, so be conservative and | ||
// say the same as double. | ||
template <> struct ToStringBuf<float> { | ||
static const unsigned kBytes = 18; | ||
}; | ||
|
||
char *ToString(double value, char *to); | ||
char *ToString(float value, char *to); | ||
|
||
} // namespace util | ||
|
||
#endif // UTIL_FLOAT_TO_STRING_H |
Oops, something went wrong.