Functionality for converting floats to strings inside the kernel, used primarily for logging.
Author:
Juniper Beatitudes
Type | Name |
---|---|
enum | bea_ftoa_result
The result indicator of the bea_ftoa _
function._ |
Type | Name |
---|---|
enum bea_ftoa_result | bea_ftoa
(float x, char *buf, size_t n_available, bool include_positive_sign)
Fills a buffer with a string representation of a single-precision IEEE-754 floating point number. |
bea_ftoa_result
The result indicator of the bea_ftoa
_
function._
enum bea_ftoa_result {
,
BEA_FTOA_SUCCESS,
BEA_FTOA_ENOSPACE
BEA_FTOA_WPRECISIONLOSS};
bea_ftoa
Fills a buffer with a string representation of a single-precision IEEE-754 floating point number.
enum bea_ftoa_result bea_ftoa (
float x,
char *buf,
size_t n_available,
bool include_positive_sign
)
Parameters:
x
The number to stringifybuf
The output buffern_available
The number of characters available in the
output buffer; all characters will be usedinclude_positive_sign
Boolean indicating whether or not
a sign character should be emitted if x
is positiveReturns:
BEA_FTOA_SUCCESS Represents a fully successful run with no loss-of-precision warning
Returns:
BEA_FTOA_ENOSPACE Indicates that there is insufficient space in the buffer to represent the integral portion of the number
Returns:
BEA_FTOA_WPRECISIONLOSS Indicates that there are more significant digits emitted than a single-precision floating point number actually has
Todo
Add support for emitting INF, NaN
Add support for scientific notation