From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on inbox.vuxu.org X-Spam-Level: X-Spam-Status: No, score=0.0 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, FREEMAIL_FROM autolearn=ham autolearn_force=no version=3.4.4 Received: (qmail 13491 invoked from network); 18 Aug 2021 23:26:27 -0000 Received: from 1ess.inri.net (216.126.196.35) by inbox.vuxu.org with ESMTPUTF8; 18 Aug 2021 23:26:27 -0000 Received: from mout.gmx.net ([212.227.15.18]) by 1ess; Wed Aug 18 18:58:44 -0400 2021 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gmx.net; s=badeba3b8450; t=1629327511; bh=Fi9H3XUjCqglD55jbcurhmru7L23LhKuxbPM/cspFWI=; h=X-UI-Sender-Class:Date:From:To:Subject:In-Reply-To:References; b=HQeoct1fo30qW1bjfMDDaf5C67gkkDQhK8H6ebCDlYQwnP2dyfsOGv8SutpeNG+L8 mUdTnJomnmhdinwA0Ki6GDX9qdBtewCaL0B6Zfwh9ABHNnRnhG7pTxOp7p8fD45J5l wKn6EL3rmkoGLxEHEDUBAae445e73mbH04yeLqmk= X-UI-Sender-Class: 01bb95c1-4bf8-414a-932a-4f6e2808ef9c Received: from localhost ([185.97.182.81]) by mail.gmx.net (mrgmx005 [212.227.17.190]) with ESMTPSA (Nemesis) id 1M2O6e-1mDj0y2C3q-003t8N for <9front@9front.org>; Thu, 19 Aug 2021 00:53:26 +0200 Date: Thu, 19 Aug 2021 00:53:47 +0200 From: Eckard Brauer To: 9front@9front.org Message-ID: <20210819005347.6a6db0a6@gmx.de> In-Reply-To: <20210816164504.4341615e@spruce.localdomain> References: <20210816164504.4341615e@spruce.localdomain> X-Mailer: Claws Mail 3.17.8 (GTK+ 2.24.33; x86_64-pc-linux-gnu) Face: iVBORw0KGgoAAAANSUhEUgAAADAAAAAwCAIAAADYYG7QAAAAAXNSR0IArs4c6QAAAllJREFUWMPtmN11o0AMRi/ZrWCmBakGapgakhbWxZAaUoNqwC1INaiGfcBJgNixN46zfmAeOBxbB935Rn/QyeDc03rgztYGtAFtQBvQBrQB/RiQwg70foAagN+LQgrIAUd/EkiP+Zt+kfDg+5l+f6YB7id8CcSSZG53zUF2bxOjwtBAThjGEU/ha4PV8tMP87MKCW72LLhOeAIIqjNCEdG1UB+1i/MyBEAY4Fgs4Lr5TK14I8RM3eceYxLQQUGm49GJEFhBv170Qq6duc2Mu49DfsPVrLl9Gj1rmWK2LWttGXyuK2lfVQlkFaZHgtrQaCAqNugJCCJmRyZvNt52phLocpfNZingFwb1kcT+INWrGDEBeCx1aH+e285vlPYOjkZTRLGhzf/bibTdwcrCB9cIEDxo19ahX+Xw6MXK2c1YtfR9FqXLLjOBkZJj5CgRSdZekWZVS2YtZKVS8/o69Hm99ikHPSQMdwUZNBAsjGYq76X0UDKFdSR9N9AhAd8yRHEITjn2YzX8ihg6FekThbV2Ll++2N/+odvLcvc3+kbxcKEw721fkVt+LzlzZEODwULFFnBxO6Djaf9ekJ+Hmi+o7lqvmkqQ1BJUkqvS+4tAVTMildACtWdv1V8gNUfJqJUe8luxzgA9gZJmo8dYyPRIy+yoPZnZ56hp1H0PCUm9OVCSWjstZZ9dkhEelW7qwRYlsnYJlBxrRla5nuksUE0PyOwfx5d99E/RP46BZXS17LOQJTsyoSSpUa8dry+o1FO313a8FvtyetV2e6DtVXoD2oA2oA3ov66/BWQZa7j3R/gAAAAASUVORK5CYII= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable X-Provags-ID: V03:K1:d+D+NMCUyrQrMXUZGdOLl957RaeswbxEQ86DFWgVCTf5btit5cl ZWInb42gfKXWw7IzkTeYuAe86n4H75+OnoaK5uJ0GKGM8ftHPae9iuDdpS9n8vgS0cx9y8Q O2f3U2CKVBQpa+Z/avTnRKt1Unq7C7BHQA4qmvuK89gD/mKtn+2/+ZT5C0yedjKanAwdCRv dugTNp+Ji7GIEz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XrHXzx aEyCUyahMn3bxSWXS+O0xjaIPb7iIkComb2THEr9pT0b9rt3HNEky6tyd6O/TY94KgFYu7fqb jshn+OnnIXM/VsUl+fr3vfWEjwfN763W/2GHlJ50uRZGYvXqxovBX5eHQ== List-ID: <9front.9front.org> List-Help: X-Glyph: ➈ X-Bullshit: decentralized stateless core-oriented hardware metadata-based backend Subject: Re: [9front] seq: fix infinite loop Reply-To: 9front@9front.org Precedence: bulk Am Mon, 16 Aug 2021 16:45:04 -0500 schrieb Amavect : > On Sun, 15 Aug 2021 15:02:38 -0700 > Sean Hinchee wrote: > [...] =20 > At this range, 2e16 and 20000000000000002 are represented by the same > double floating point value. >=20 > [...] =20 > We can cover more cases. > For example, your patch does not fix the following: > seq 9007199254740992 9007199254740996 > The issue is with floating point precision. >=20 > A double has a 52 bit mantissa, meaning that it allows 2^52 different > values before the exponent is incremented (thus, floating point.) > A double has a 11 bit exponent, and 1 sign bit. > Exponents range from =E2=88=921022 to +1023, with exponents =E2=88=921023= and > +1024 reserved for special numbers. >=20 > At an exponent e, the mantissa represents a value between > [2^e,2^(e+1)). The precision is range/buckets, so we can calculate > the precision. At an exponent e and mantissa m, the precision is > 2^(e-m) (2^(e+1)-2^e)/2^m =3D 2^e/2^m =3D 2^(e-m) >=20 > Between [1, 2), the exponent is 0. > The precision is 2^(0-52) =E2=89=88 0.0000000000000002220446 > Between [2^52, 2^53), the exponent is 52. > The precision is 2^(52-52) =3D 1. >=20 > 2e16 is between [2^54, 2^55), so the exponent is 54. > The precision is 2^(54-52) =3D 4. > Halfway ties round to the even bucket. >=20 > This is demonstrated by the following. >=20 > # infinite loop > seq 2e16 19999999999999998 >=20 > # 2^53-1, halts > seq 9007199254740991 9007199254740991 >=20 > # 2^53, infinite loop due to halfway tie rounding down to even bucket. > seq 9007199254740992 9007199254740992 > # halts, halfway tie rounds up to even bucket, 9007199254740996 > seq 9007199254740994 9007199254740994 >=20 > # different due to rounding error in loss of precision > seq 5000000000000000 1.1 5000000000000002 > seq 0 1.1 2 >=20 >=20 > I don't believe that there is an ideal resolution to rounding error in > that last example (libmp would be too complex), but we can cover more > cases if we check that the previous val value is different from the > current val. > The correct thing to do is to throw an error warning about precision. >=20 > Thanks, > Amavect IMHO the args could easily be double, the internal counter can never. seq could be kind of that: if (argc =3D=3D 3) delta =3D argv[2]; else delta =3D 1; if (!(argv[1] + delta > argv[1])) error(...); for (ulong i=3D0; i