Re: [PATCH 1/3] utils: Improve qemu_strtosz() to have 64 bits of precision

2021-02-05 Thread Daniel P . Berrangé
On Fri, Feb 05, 2021 at 08:27:14AM -0600, Eric Blake wrote: > On 2/5/21 5:02 AM, Daniel P. Berrangé wrote: > > >> /* > >> - * Convert string to bytes, allowing either B/b for bytes, K/k for KB, > >> - * M/m for MB, G/g for GB or T/t for TB. End pointer will be returned > >> - * in *end, if not NU

Re: [PATCH 1/3] utils: Improve qemu_strtosz() to have 64 bits of precision

2021-02-05 Thread Eric Blake
On 2/5/21 5:34 AM, Daniel P. Berrangé wrote: > On Thu, Feb 04, 2021 at 01:07:06PM -0600, Eric Blake wrote: >> We have multiple clients of qemu_strtosz (qemu-io, the opts visitor, >> the keyval visitor), and it gets annoying that edge-case testing is >> impacted by implicit rounding to 53 bits of pr

Re: [PATCH 1/3] utils: Improve qemu_strtosz() to have 64 bits of precision

2021-02-05 Thread Eric Blake
On 2/5/21 5:02 AM, Daniel P. Berrangé wrote: >> /* >> - * Convert string to bytes, allowing either B/b for bytes, K/k for KB, >> - * M/m for MB, G/g for GB or T/t for TB. End pointer will be returned >> - * in *end, if not NULL. Return -ERANGE on overflow, and -EINVAL on >> - * other error. >> +

Re: [PATCH 1/3] utils: Improve qemu_strtosz() to have 64 bits of precision

2021-02-05 Thread Eric Blake
On 2/5/21 4:28 AM, Richard W.M. Jones wrote: > On Thu, Feb 04, 2021 at 01:07:06PM -0600, Eric Blake wrote: >> We have multiple clients of qemu_strtosz (qemu-io, the opts visitor, >> the keyval visitor), and it gets annoying that edge-case testing is >> impacted by implicit rounding to 53 bits of pr

Re: [PATCH 1/3] utils: Improve qemu_strtosz() to have 64 bits of precision

2021-02-05 Thread Eric Blake
On 2/5/21 4:07 AM, Vladimir Sementsov-Ogievskiy wrote: >> @@ -2106,6 +2137,21 @@ static void test_qemu_strtosz_invalid(void) >>   err = qemu_strtosz(str, &endptr, &res); >>   g_assert_cmpint(err, ==, -EINVAL); >>   g_assert(endptr == str); >> + >> +    str = "1.1e5"; >> +    err = qemu

Re: [PATCH 1/3] utils: Improve qemu_strtosz() to have 64 bits of precision

2021-02-05 Thread Daniel P . Berrangé
On Fri, Feb 05, 2021 at 08:06:53AM -0600, Eric Blake wrote: > On 2/5/21 4:06 AM, Vladimir Sementsov-Ogievskiy wrote: > > >>> -    /* > >>> - * Values near UINT64_MAX overflow to 2**64 when converting to > >>> double > >>> - * precision.  Compare against the maximum representable double > >

Re: [PATCH 1/3] utils: Improve qemu_strtosz() to have 64 bits of precision

2021-02-05 Thread Eric Blake
On 2/5/21 4:06 AM, Vladimir Sementsov-Ogievskiy wrote: >>> -    /* >>> - * Values near UINT64_MAX overflow to 2**64 when converting to >>> double >>> - * precision.  Compare against the maximum representable double >>> precision >>> - * value below 2**64, computed as "the next value af

Re: [PATCH 1/3] utils: Improve qemu_strtosz() to have 64 bits of precision

2021-02-05 Thread Daniel P . Berrangé
On Thu, Feb 04, 2021 at 01:07:06PM -0600, Eric Blake wrote: > We have multiple clients of qemu_strtosz (qemu-io, the opts visitor, > the keyval visitor), and it gets annoying that edge-case testing is > impacted by implicit rounding to 53 bits of precision due to parsing > with strtod(). As an exa

Re: [PATCH 1/3] utils: Improve qemu_strtosz() to have 64 bits of precision

2021-02-05 Thread Daniel P . Berrangé
On Thu, Feb 04, 2021 at 01:07:06PM -0600, Eric Blake wrote: > We have multiple clients of qemu_strtosz (qemu-io, the opts visitor, > the keyval visitor), and it gets annoying that edge-case testing is > impacted by implicit rounding to 53 bits of precision due to parsing > with strtod(). As an exa

Re: [PATCH 1/3] utils: Improve qemu_strtosz() to have 64 bits of precision

2021-02-05 Thread Richard W.M. Jones
On Thu, Feb 04, 2021 at 01:07:06PM -0600, Eric Blake wrote: > We have multiple clients of qemu_strtosz (qemu-io, the opts visitor, > the keyval visitor), and it gets annoying that edge-case testing is > impacted by implicit rounding to 53 bits of precision due to parsing > with strtod(). As an exa

Re: [PATCH 1/3] utils: Improve qemu_strtosz() to have 64 bits of precision

2021-02-05 Thread Vladimir Sementsov-Ogievskiy
05.02.2021 13:06, Vladimir Sementsov-Ogievskiy wrote: 04.02.2021 23:12, Eric Blake wrote: On 2/4/21 1:07 PM, Eric Blake wrote: We have multiple clients of qemu_strtosz (qemu-io, the opts visitor, the keyval visitor), and it gets annoying that edge-case testing is impacted by implicit rounding t

Re: [PATCH 1/3] utils: Improve qemu_strtosz() to have 64 bits of precision

2021-02-05 Thread Vladimir Sementsov-Ogievskiy
04.02.2021 22:07, Eric Blake wrote: We have multiple clients of qemu_strtosz (qemu-io, the opts visitor, the keyval visitor), and it gets annoying that edge-case testing is impacted by implicit rounding to 53 bits of precision due to parsing with strtod(). As an example posted by Rich Jones: $

Re: [PATCH 1/3] utils: Improve qemu_strtosz() to have 64 bits of precision

2021-02-05 Thread Vladimir Sementsov-Ogievskiy
04.02.2021 23:12, Eric Blake wrote: On 2/4/21 1:07 PM, Eric Blake wrote: We have multiple clients of qemu_strtosz (qemu-io, the opts visitor, the keyval visitor), and it gets annoying that edge-case testing is impacted by implicit rounding to 53 bits of precision due to parsing with strtod(). A

Re: [PATCH 1/3] utils: Improve qemu_strtosz() to have 64 bits of precision

2021-02-04 Thread Eric Blake
On 2/4/21 1:07 PM, Eric Blake wrote: > We have multiple clients of qemu_strtosz (qemu-io, the opts visitor, > the keyval visitor), and it gets annoying that edge-case testing is > impacted by implicit rounding to 53 bits of precision due to parsing > with strtod(). As an example posted by Rich Jon

[PATCH 1/3] utils: Improve qemu_strtosz() to have 64 bits of precision

2021-02-04 Thread Eric Blake
We have multiple clients of qemu_strtosz (qemu-io, the opts visitor, the keyval visitor), and it gets annoying that edge-case testing is impacted by implicit rounding to 53 bits of precision due to parsing with strtod(). As an example posted by Rich Jones: $ nbdkit memory $(( 2**63 - 2**30 )) --r