+ /* Interpret as a (finite positive) float number */
+ const int ubits = CHAR_BIT * sizeof (unsigned);
+ int exp;
+ double f = frexp(us_atof(tmp), &exp);
+
+ if (!isgreaterequal(f, 0.))
+ goto error; /* negative or not a number */
+
+ if (exp <= 1 - ubits) {
+ n = 0; /* too small */
+ d = 1;
+ } else if (exp <= 0) {
+ n = floor(scalbn(f, ubits - 1 + exp));
+#if (FLT_RADIX != 2)
+# error Floating point configuration not supported.
+#endif
+ d = 1u << (ubits - 1);
+ } else if (exp <= ubits) {
+ n = floor(scalbn(f, ubits));
+ d = 1u << (ubits - exp);
+ } else
+ goto error; /* too big */