Rocksolid Light

Welcome to novaBBS (click a section below)

mail  files  register  newsreader  groups  login

Message-ID:  

Nobody said computers were going to be polite.


devel / comp.arch / Double Rounding Floating Point

SubjectAuthor
* Double Rounding Floating PointMitchAlsup
+- Re: Double Rounding Floating PointTerje Mathisen
+* Re: Double Rounding Floating PointMichael S
|`* Re: Double Rounding Floating Pointantispam
| `- Re: Double Rounding Floating PointMichael S
`- Re: Double Rounding Floating PointJulio Di Egidio

1
Double Rounding Floating Point

<4acd05cf-de86-4519-a190-44fc21428173n@googlegroups.com>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=20790&group=comp.arch#20790

  copy link   Newsgroups: comp.arch
X-Received: by 2002:a37:444d:: with SMTP id r74mr4435262qka.405.1633721670244;
Fri, 08 Oct 2021 12:34:30 -0700 (PDT)
X-Received: by 2002:a9d:2f24:: with SMTP id h33mr10594646otb.254.1633721670017;
Fri, 08 Oct 2021 12:34:30 -0700 (PDT)
Path: rocksolid2!i2pn.org!weretis.net!feeder6.news.weretis.net!news.misty.com!border2.nntp.dca1.giganews.com!nntp.giganews.com!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
Newsgroups: comp.arch
Date: Fri, 8 Oct 2021 12:34:29 -0700 (PDT)
Injection-Info: google-groups.googlegroups.com; posting-host=2600:1700:291:29f0:7cbe:94e8:31db:6e9f;
posting-account=H_G_JQkAAADS6onOMb-dqvUozKse7mcM
NNTP-Posting-Host: 2600:1700:291:29f0:7cbe:94e8:31db:6e9f
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <4acd05cf-de86-4519-a190-44fc21428173n@googlegroups.com>
Subject: Double Rounding Floating Point
From: MitchAl...@aol.com (MitchAlsup)
Injection-Date: Fri, 08 Oct 2021 19:34:30 +0000
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
Lines: 25
 by: MitchAlsup - Fri, 8 Oct 2021 19:34 UTC

I found the following paragraph

"Apart from the 𝑟𝑛𝑒 rounding mode, there are four other rounding modes in the IEEE-754 standard. When existing correctly rounded libraries are used to generate results with other rounding modes or with other precision configurations, it can produce wrong results due to double rounding. For
example, let us say we use a correctly rounded double precision library such as CR-LIBM with the 𝑟𝑛𝑒 rounding mode to produce results for a 32-bit float type with the same 𝑟𝑛𝑒 mode. Here, we round the result of CR-LIBM to a 32-bit float value to produce the final result. If the real value of 𝑓 (𝑥) is extremely close to the rounding boundary of two adjacent float values, then the error caused by rounding 𝑓 (𝑥) to double using the 𝑟𝑛𝑒 mode can be significant enough to produce the wrong result for a 32-bit float. We empirically show that this approach of using a correctly rounded math library for double precision produces wrong float results in Section 6."

in https://arxiv.org/pdf/2108.06756.pdf

A while back, some people on this NG told me that computing in double and then rounding to single did not produce double rounding errors. Something about 2n+3 fraction bits being sufficient.

Here is the evidence against that position.

Re: Double Rounding Floating Point

<sjqco1$1jr4$1@gioia.aioe.org>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=20792&group=comp.arch#20792

  copy link   Newsgroups: comp.arch
Path: rocksolid2!news.neodome.net!news.mixmin.net!aioe.org!rd9pRsUZyxkRLAEK7e/Uzw.user.46.165.242.91.POSTED!not-for-mail
From: terje.ma...@tmsw.no (Terje Mathisen)
Newsgroups: comp.arch
Subject: Re: Double Rounding Floating Point
Date: Fri, 8 Oct 2021 23:21:04 +0200
Organization: Aioe.org NNTP Server
Message-ID: <sjqco1$1jr4$1@gioia.aioe.org>
References: <4acd05cf-de86-4519-a190-44fc21428173n@googlegroups.com>
Mime-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
Injection-Info: gioia.aioe.org; logging-data="53092"; posting-host="rd9pRsUZyxkRLAEK7e/Uzw.user.gioia.aioe.org"; mail-complaints-to="abuse@aioe.org";
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:60.0) Gecko/20100101
Firefox/60.0 SeaMonkey/2.53.9.1
X-Notice: Filtered by postfilter v. 0.9.2
 by: Terje Mathisen - Fri, 8 Oct 2021 21:21 UTC

MitchAlsup wrote:
> I found the following paragraph
>
> "Apart from the 𝑟𝑛𝑒 rounding mode, there are four other rounding modes in the IEEE-754 standard. When existing correctly rounded libraries are used to generate results with other rounding modes or with other precision configurations, it can produce wrong results due to double rounding. For
> example, let us say we use a correctly rounded double precision library such as CR-LIBM with the 𝑟𝑛𝑒 rounding mode to produce results for a 32-bit float type with the same 𝑟𝑛𝑒 mode. Here, we round the result of CR-LIBM to a 32-bit float value to produce the final result. If the real value of 𝑓 (𝑥) is extremely close to the rounding boundary of two adjacent float values, then the error caused by rounding 𝑓 (𝑥) to double using the 𝑟𝑛𝑒 mode can be significant enough to produce the wrong result for a 32-bit float. We empirically show that this approach of using a correctly rounded math library for double precision produces wrong float results in Section 6."
>
> in https://arxiv.org/pdf/2108.06756.pdf
>
> A while back, some people on this NG told me that computing in double and then rounding to single did not produce double rounding errors. Something about 2n+3 fraction bits being sufficient.
>
> Here is the evidence against that position.
>
Without reading the linked paper, I would guess that they cannot get
this "extremely close to the rounding boundary" result from a single
operation. If you do multiple ops, all in double, then you can indeed
get results that will be different after double rounding.

Terje
--
- <Terje.Mathisen at tmsw.no>
"almost all programming can be viewed as an exercise in caching"

Re: Double Rounding Floating Point

<cad16dcd-4bd9-4104-8882-652a73cf2383n@googlegroups.com>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=21028&group=comp.arch#21028

  copy link   Newsgroups: comp.arch
X-Received: by 2002:a37:43c6:: with SMTP id q189mr23931837qka.315.1634122205327;
Wed, 13 Oct 2021 03:50:05 -0700 (PDT)
X-Received: by 2002:aca:5f09:: with SMTP id t9mr7595812oib.157.1634122205113;
Wed, 13 Oct 2021 03:50:05 -0700 (PDT)
Path: rocksolid2!i2pn.org!weretis.net!feeder6.news.weretis.net!news.misty.com!border2.nntp.dca1.giganews.com!nntp.giganews.com!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
Newsgroups: comp.arch
Date: Wed, 13 Oct 2021 03:50:04 -0700 (PDT)
In-Reply-To: <4acd05cf-de86-4519-a190-44fc21428173n@googlegroups.com>
Injection-Info: google-groups.googlegroups.com; posting-host=199.203.251.52; posting-account=ow8VOgoAAAAfiGNvoH__Y4ADRwQF1hZW
NNTP-Posting-Host: 199.203.251.52
References: <4acd05cf-de86-4519-a190-44fc21428173n@googlegroups.com>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <cad16dcd-4bd9-4104-8882-652a73cf2383n@googlegroups.com>
Subject: Re: Double Rounding Floating Point
From: already5...@yahoo.com (Michael S)
Injection-Date: Wed, 13 Oct 2021 10:50:05 +0000
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
Lines: 37
 by: Michael S - Wed, 13 Oct 2021 10:50 UTC

On Friday, October 8, 2021 at 10:34:31 PM UTC+3, MitchAlsup wrote:
> I found the following paragraph
>
> "Apart from the 𝑟𝑛𝑒 rounding mode, there are four other rounding modes in the IEEE-754 standard. When existing correctly rounded libraries are used to generate results with other rounding modes or with other precision configurations, it can produce wrong results due to double rounding. For
> example, let us say we use a correctly rounded double precision library such as CR-LIBM with the 𝑟𝑛𝑒 rounding mode to produce results for a 32-bit float type with the same 𝑟𝑛𝑒 mode. Here, we round the result of CR-LIBM to a 32-bit float value to produce the final result. If the real value of 𝑓 (𝑥) is extremely close to the rounding boundary of two adjacent float values, then the error caused by rounding 𝑓 (𝑥) to double using the 𝑟𝑛𝑒 mode can be significant enough to produce the wrong result for a 32-bit float. We empirically show that this approach of using a correctly rounded math library for double precision produces wrong float results in Section 6."
>
> in https://arxiv.org/pdf/2108.06756.pdf
>
> A while back, some people on this NG told me that computing in double and then rounding to single did not produce double rounding errors. Something about 2n+3 fraction bits being sufficient.
>
> Here is the evidence against that position.

They say that it can happen when you do calculation in binary64 under RNE and then round result to binary32 under non-RNE.
The claim in NG was about the case when final step is also done under RNE.

BTW, even original claim was made only +,-,*,/ and sqrt(). Nobody said that it is correct to any imaginable transcendental.
I think (didn't check) that correctness of the claim is proven by exhausting for all transcendental functions of single argument that are present in clib. But for arbitrary "smooth" transcendental functions it's just should be consider very likely until proven.

Re: Double Rounding Floating Point

<8c0314e9-0797-4bd3-84fd-7269345aa3f5n@googlegroups.com>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=21032&group=comp.arch#21032

  copy link   Newsgroups: comp.arch
X-Received: by 2002:a37:44cc:: with SMTP id r195mr25409665qka.77.1634126435971;
Wed, 13 Oct 2021 05:00:35 -0700 (PDT)
X-Received: by 2002:a05:6808:180c:: with SMTP id bh12mr8010284oib.78.1634126435299;
Wed, 13 Oct 2021 05:00:35 -0700 (PDT)
Path: rocksolid2!news.neodome.net!weretis.net!feeder6.news.weretis.net!news.misty.com!border2.nntp.dca1.giganews.com!border1.nntp.dca1.giganews.com!nntp.giganews.com!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
Newsgroups: comp.arch
Date: Wed, 13 Oct 2021 05:00:35 -0700 (PDT)
In-Reply-To: <4acd05cf-de86-4519-a190-44fc21428173n@googlegroups.com>
Injection-Info: google-groups.googlegroups.com; posting-host=93.41.98.54; posting-account=F3H0JAgAAADcYVukktnHx7hFG5stjWse
NNTP-Posting-Host: 93.41.98.54
References: <4acd05cf-de86-4519-a190-44fc21428173n@googlegroups.com>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <8c0314e9-0797-4bd3-84fd-7269345aa3f5n@googlegroups.com>
Subject: Re: Double Rounding Floating Point
From: jul...@diegidio.name (Julio Di Egidio)
Injection-Date: Wed, 13 Oct 2021 12:00:35 +0000
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
Lines: 39
 by: Julio Di Egidio - Wed, 13 Oct 2021 12:00 UTC

On Friday, 8 October 2021 at 21:34:31 UTC+2, MitchAlsup wrote:
> I found the following paragraph
>
> "Apart from the 𝑟𝑛𝑒 rounding mode, there are four other rounding modes in the IEEE-754 standard. When existing correctly rounded libraries are used to generate results with other rounding modes or with other precision configurations, it can produce wrong results due to double rounding.
>
> For
> example, let us say we use a correctly rounded double precision library such as CR-LIBM with the 𝑟𝑛𝑒 rounding mode to produce results for a 32-bit float type with the same 𝑟𝑛𝑒 mode. Here, we round the result of CR-LIBM to a 32-bit float value to produce the final result. If the real value of 𝑓 (𝑥) is extremely close to the rounding boundary of two adjacent float values, then the error caused by rounding 𝑓 (𝑥) to double using the 𝑟𝑛𝑒 mode can be significant enough to produce the wrong result for a 32-bit float. We empirically show that this approach of using a correctly rounded math library for double precision produces wrong float results in Section 6."
>
> in https://arxiv.org/pdf/2108.06756.pdf

That is completely a misunderstanding: rounding modes are set against the FPU, so just assuming default rounding is rather a naive mistake on the part of the developer.

There is *no such thing* as an a priori "correctly rounded library", and there are just no such problems as the authors here elucubrate.

HTH,

Julio

> A while back, some people on this NG told me that computing in double and then rounding to single did not produce double rounding errors. Something about 2n+3 fraction bits being sufficient.
>
> Here is the evidence against that position.

Re: Double Rounding Floating Point

<sk6lrv$f9r$1@z-news.wcss.wroc.pl>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=21046&group=comp.arch#21046

  copy link   Newsgroups: comp.arch
Path: rocksolid2!news.neodome.net!3.eu.feeder.erje.net!feeder.erje.net!newsfeed.pionier.net.pl!pwr.wroc.pl!news.wcss.wroc.pl!not-for-mail
From: antis...@math.uni.wroc.pl
Newsgroups: comp.arch
Subject: Re: Double Rounding Floating Point
Date: Wed, 13 Oct 2021 13:10:23 +0000 (UTC)
Organization: Politechnika Wroclawska
Lines: 33
Message-ID: <sk6lrv$f9r$1@z-news.wcss.wroc.pl>
References: <4acd05cf-de86-4519-a190-44fc21428173n@googlegroups.com> <cad16dcd-4bd9-4104-8882-652a73cf2383n@googlegroups.com>
NNTP-Posting-Host: hera.math.uni.wroc.pl
X-Trace: z-news.wcss.wroc.pl 1634130623 15675 156.17.86.1 (13 Oct 2021 13:10:23 GMT)
X-Complaints-To: abuse@news.pwr.wroc.pl
NNTP-Posting-Date: Wed, 13 Oct 2021 13:10:23 +0000 (UTC)
Cancel-Lock: sha1:oELM2qTzOmvrnPqRiGAFrfXzK0o=
User-Agent: tin/2.4.3-20181224 ("Glen Mhor") (UNIX) (Linux/4.19.0-10-amd64 (x86_64))
 by: antis...@math.uni.wroc.pl - Wed, 13 Oct 2021 13:10 UTC

Michael S <already5chosen@yahoo.com> wrote:
> On Friday, October 8, 2021 at 10:34:31 PM UTC+3, MitchAlsup wrote:
> > I found the following paragraph
> >
> > "Apart from the ??? rounding mode, there are four other rounding modes in the IEEE-754 standard. When existing correctly rounded libraries are used to generate results with other rounding modes or with other precision configurations, it can produce wrong results due to double rounding. For
> > example, let us say we use a correctly rounded double precision library such as CR-LIBM with the ??? rounding mode to produce results for a 32-bit float type with the same ??? mode. Here, we round the result of CR-LIBM to a 32-bit float value to produce the final result. If the real value of ? (?) is extremely close to the rounding boundary of two adjacent float values, then the error caused by rounding ? (?) to double using the ??? mode can be significant enough to produce the wrong result for a 32-bit float. We empirically show that this approach of using a correctly rounded math library for double precision produces wrong float results in Section 6."
> >
> > in https://arxiv.org/pdf/2108.06756.pdf
> >
> > A while back, some people on this NG told me that computing in double and then rounding to single did not produce double rounding errors. Something about 2n+3 fraction bits being sufficient.
> >
> > Here is the evidence against that position.
>
> They say that it can happen when you do calculation in binary64 under RNE and then round result to binary32 under non-RNE.
> The claim in NG was about the case when final step is also done under RNE.
>
> BTW, even original claim was made only +,-,*,/ and sqrt(). Nobody said that it is correct to any imaginable transcendental.
> I think (didn't check) that correctness of the claim is proven by exhausting for all transcendental functions of single argument that are present in clib. But for arbitrary "smooth" transcendental functions it's just should be consider very likely until proven.

Original claim was about single arithemtic operation. It is not valid
for sequence of operations (I you want to emulate seqence of single
precision operations you need to insert rounding to single after
each step). Proof for arithmetic is easy: when arguments have
single precision in most cases result can be represented exactly
in double precision. Remaining cases are special enough
to handle by slightly different argment. Such reasoning breaks
down for transcendental functions and even sqrt. Of couse,
result could be valid due to more subtle reasons, but for
resonably general transcendental functions this is highly
unlikely. So I would say: very unlikely unless proven.

--
Waldek Hebisch

Re: Double Rounding Floating Point

<e2c095f2-38ce-4a58-a6d4-6531ff408386n@googlegroups.com>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=21052&group=comp.arch#21052

  copy link   Newsgroups: comp.arch
X-Received: by 2002:a05:622a:60a:: with SMTP id z10mr29644510qta.209.1634135893276;
Wed, 13 Oct 2021 07:38:13 -0700 (PDT)
X-Received: by 2002:a4a:4fcf:: with SMTP id c198mr28684403oob.26.1634135893037;
Wed, 13 Oct 2021 07:38:13 -0700 (PDT)
Path: rocksolid2!news.neodome.net!weretis.net!feeder6.news.weretis.net!news.misty.com!border2.nntp.dca1.giganews.com!nntp.giganews.com!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
Newsgroups: comp.arch
Date: Wed, 13 Oct 2021 07:38:12 -0700 (PDT)
In-Reply-To: <sk6lrv$f9r$1@z-news.wcss.wroc.pl>
Injection-Info: google-groups.googlegroups.com; posting-host=199.203.251.52; posting-account=ow8VOgoAAAAfiGNvoH__Y4ADRwQF1hZW
NNTP-Posting-Host: 199.203.251.52
References: <4acd05cf-de86-4519-a190-44fc21428173n@googlegroups.com>
<cad16dcd-4bd9-4104-8882-652a73cf2383n@googlegroups.com> <sk6lrv$f9r$1@z-news.wcss.wroc.pl>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <e2c095f2-38ce-4a58-a6d4-6531ff408386n@googlegroups.com>
Subject: Re: Double Rounding Floating Point
From: already5...@yahoo.com (Michael S)
Injection-Date: Wed, 13 Oct 2021 14:38:13 +0000
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
Lines: 83
 by: Michael S - Wed, 13 Oct 2021 14:38 UTC

On Wednesday, October 13, 2021 at 4:10:24 PM UTC+3, anti...@math.uni.wroc.pl wrote:
> Michael S <already...@yahoo.com> wrote:
> > On Friday, October 8, 2021 at 10:34:31 PM UTC+3, MitchAlsup wrote:
> > > I found the following paragraph
> > >
> > > "Apart from the ??? rounding mode, there are four other rounding modes in the IEEE-754 standard. When existing correctly rounded libraries are used to generate results with other rounding modes or with other precision configurations, it can produce wrong results due to double rounding. For
> > > example, let us say we use a correctly rounded double precision library such as CR-LIBM with the ??? rounding mode to produce results for a 32-bit float type with the same ??? mode. Here, we round the result of CR-LIBM to a 32-bit float value to produce the final result. If the real value of ? (?) is extremely close to the rounding boundary of two adjacent float values, then the error caused by rounding ? (?) to double using the ??? mode can be significant enough to produce the wrong result for a 32-bit float. We empirically show that this approach of using a correctly rounded math library for double precision produces wrong float results in Section 6."
> > >
> > > in https://arxiv.org/pdf/2108.06756.pdf
> > >
> > > A while back, some people on this NG told me that computing in double and then rounding to single did not produce double rounding errors. Something about 2n+3 fraction bits being sufficient.
> > >
> > > Here is the evidence against that position.
> >
> > They say that it can happen when you do calculation in binary64 under RNE and then round result to binary32 under non-RNE.
> > The claim in NG was about the case when final step is also done under RNE.
> >
> > BTW, even original claim was made only +,-,*,/ and sqrt(). Nobody said that it is correct to any imaginable transcendental.
> > I think (didn't check) that correctness of the claim is proven by exhausting for all transcendental functions of single argument that are present in clib. But for arbitrary "smooth" transcendental functions it's just should be consider very likely until proven.
> Original claim was about single arithemtic operation. It is not valid
> for sequence of operations (I you want to emulate seqence of single
> precision operations you need to insert rounding to single after
> each step). Proof for arithmetic is easy: when arguments have
> single precision in most cases result can be represented exactly
> in double precision. Remaining cases are special enough
> to handle by slightly different argment. Such reasoning breaks
> down for transcendental functions and even sqrt. Of couse,
> result could be valid due to more subtle reasons, but for
> resonably general transcendental functions this is highly
> unlikely. So I would say: very unlikely unless proven.
>
> --
> Waldek Hebisch

Yes, for general case I miscalculated.
For general "smooth" transcendental function that takes input in the full binary32 range
and produces output in the same range it could be assumed that for any particular input value
a probability of double rounding mistake = 2**(24-53).
Strictly speaking, the formula applies only to results in "normal" binary32 range, for subnormal the formula is different,
but let's ignore subnormals for sake of brevity.
Using formula above we can estimate a probability that none of the possible binary32 inputs
will suffer from double rounding mistake as (1-2**(24-53))**(2**32) ~= exp(-8)=3.35e-4.
I other words, you are right.

Of course, as you said, for specific transcendental there can be reasons why probability differs.
For example, if the function is even or odd then the number of different inputs is twice smaller
and then probability of absence of mistake ~= exp(-4) = 1.83e-2. Still pretty small number.

Or, for example, for sin(x) we know that there are no mistakes as long as x*x/3 < ULP(x).
That cuts off almost half of possible inputs.
Etc...

1
server_pubkey.txt

rocksolid light 0.9.8
clearnet tor