|
From: | Tao Xu |
Subject: | Re: [PATCH v17 02/14] util/cutils: Use qemu_strtold_finite to parse size |
Date: | Tue, 26 Nov 2019 16:31:56 +0800 |
User-agent: | Mozilla/5.0 (Windows NT 10.0; WOW64; rv:60.0) Gecko/20100101 Thunderbird/60.9.1 |
On 11/25/2019 2:56 PM, Markus Armbruster wrote:
Tao Xu <address@hidden> writes:Support full 64bit precision, modify related test cases.That's not true in general: long double need not be any wider than double. It might be true on the host machines we support, but I don't know. If we decide to rely on it, we better make the build fail when the host machine doesn't meet our expectations, preferably in configure.
[...]
- if ((val * mul >= 0xfffffffffffffc00) || val < 0) { + /* Values > UINT64_MAX overflow uint64_t */ + if ((val * mul > UINT64_MAX) || val < 0) { retval = -ERANGE; goto out; }Not portable. If it was, we'd have made this changd long ago :)
OK. So the suitable solution is what you suggested in v14?"A possible alternative is to parse the numeric part both as a double and as a 64 bit unsigned integer, then use whatever consumes more characters. This enables providing full 64 bits unless you actually use
a fraction." I will try this way.
[Prev in Thread] | Current Thread | [Next in Thread] |