On 11/15/18 11:25 AM, David Hildenbrand wrote:
Also, just overflow. Floating-point underflow is when a computation's
mathematical result is too close to zero to be represented without
extraordinary rounding error.
works like qemu_strtoul(). I'd prefer longhand for qemu_strtod(). It
costs us a few lines, but it results in a clearer contract.
/**
* Convert string @nptr to a double.
*
* This is a wrapper around strtod() that is harder to misuse.
* Semantics of @nptr and @endptr match strtod() with differences
* noted below.
*
* @nptr may be null, and no conversion is performed then.
*
* If no conversion is performed, store @nptr in *@endptr and return
* -EINVAL.
*
* If @endptr is null, and the string isn't fully converted, return
* -EINVAL. This is the case when the pointer that would be stored in
* a non-null @endptr points to a character other than '\0'.
*
* If the conversion overflows @result, store +/-HUGE_VAL, depending on
* the sign, in @result and return -ERANGE.
Fails to mention underflow. Maybe add:
If the conversion underflows, store +/-0.0 in @result, depending on the
sign, and return -ERANGE.
--
Eric Blake, Principal Software Engineer
Red Hat, Inc. +1-919-301-3266
Virtualization: qemu.org | libvirt.org