ryu
ryu copied to clipboard
Add ability to specify infinity and NaN strings
trafficstars
It would be nice if a user could specify the string representation of infinity and NaN values.
For example:
- "nan" instead of "NaN"
- "inf" instead of "Infinity"
I generally agree, but I haven't found a nice way to do that.
Would something like this work? #if !defined(RYU_MEMCOPY_NAN) #define RYU_MEMCOPY_NAN int memcpy_nan( char * dest_) { memcpy( dest_, "nan", 3 ); return 3; } #endif RYU_MEMCOPY_NAN
#if !defined(RYU_MEMCOPY_INF) #define RYU_MEMCOPY_INF int memcpy_infinity( char * dest_) { memcpy( dest_, "Infinity", 8 ); return 8; } #endif RYU_MEMCOPY_INF
#if !defined(RYU_EXPONENT) #define RYU_EXPONENT 'e' #endif
...and use memcpy_nan/memcpy_infinity/RYU_EXPONENT where appropriate?