[llvm] [libc] [libc][math] Implement nan(f|l) functions (PR #76690)

via llvm-commits llvm-commits at lists.llvm.org
Wed Jan 3 11:40:22 PST 2024


================
@@ -1055,6 +1055,38 @@ hexadecimal_string_to_float(const char *__restrict src,
   return output;
 }
 
+template <class T>
+LIBC_INLINE fputil::FPBits<T> nan_from_ncharseq(const char *__restrict ncharseq,
----------------
michaelrj-google wrote:

This is mostly fine, but we can simplify this function prototype a bit more.

This function doesn't actually do anything based on the sign except set it in the result, so that can be removed here and handled in strtofloatingpoint.

The ncharseq with length can be a single string_view variable (see `src/__support/CPP/string_view.h`).

The error can be part of a struct return type, similar to `str_to_num_result`.

The actual returned value doesn't need to be an FPBits object, if we move the conversion to float elsewhere this function only needs to return a `uint64_t` (and the error).

https://github.com/llvm/llvm-project/pull/76690


More information about the llvm-commits mailing list