ryu icon indicating copy to clipboard operation
ryu copied to clipboard

Add ability to specify infinity and NaN strings

Open planet36 opened this issue 5 years ago • 2 comments
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"

planet36 avatar Dec 04 '19 02:12 planet36

I generally agree, but I haven't found a nice way to do that.

ulfjack avatar Dec 04 '19 12:12 ulfjack

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?

Snuggan avatar Aug 18 '20 09:08 Snuggan