Talk:Unit in the last place

Gap
Please define gap. Thanks, --Abdull (talk) 15:13, 6 October 2009 (UTC)

C++ and Boost.MathToolkit library
The Boost Math Toolkit library brings you here. So maybe a section showing usage of would be appropriate and useful:

float_distance(float_next(a), a); // always returns 1
 * 1) include 

Robbiemorrison (talk) 11:44, 1 November 2010 (UTC)


 * I doubt it is worth to use some random library to demonstrate usage. Especially when standard C (C99) and C++ (yet unfinished C++0x) will have this feature as nextafterf function in math.h. 1exec1 (talk) 20:26, 3 November 2010 (UTC)


 * Okay. It was the float_distance function I wished to focus on.  Perhaps using a and  b would be better? Robbiemorrison (talk) 16:21, 12 November 2010 (UTC)

What is ULP again?
It seems to me that half of this article discusses the ULP as if it's a really small number (1 or less) and the other half as if it's a really big number (224 or 253). This should be clarified in the examples. Also, what's the name of the latter type of number (biggest integer that can be represented in floating point with full accuracy)? I know I've heard a term for it before... - dcljr (talk) 19:56, 11 January 2011 (UTC)

Links are marked 'citation needed' but are OK
Most links are marked 'citation needed' but the links are correct, current and the info and source areaccurate and I don't see that any further info is needed. May I delete these items if these criteria are met?

Paul A Bristow (talk) 11:47, 26 May 2015 (UTC)
 * Links to Wikipedia pages are not considered citations. As per Citing Sources each Wikipedia article is expected to be self-contained in terms of providing reference sources and citation to them to support facts. Links to other articles are merely aids to navigation and to finding additional information. This can be important when articles are reused or printed. DES (talk) 20:07, 27 May 2015 (UTC)
 * It is statements (often sentences) which are marked 'citation needed', not links. DES (talk) 20:09, 27 May 2015 (UTC)

OK - see the Wikipedia requirements now. I have provided a citation for the Boost entry (ulp function is new unreleased and I will update when the full link is known - added 1 Sep 215).

Paul A Bristow (talk) 08:45, 28 May 2015 (UTC)

Does the article still need further "citations for verification" or can we assume that at this point we could remove the template? I think it might not be perfect yet but it should probably be enough? --Evotopid (talk) 12:19, 1 December 2016 (UTC)

Minimal exponent in the definition of ULP
User:Vincent_Lefèvre The sole purpose of $$e_\min$$ in [Handbook of Floating-Point Arithmetic] is to support subnormal numbers represented using $$e_\min$$. That is, $$e_\min$$ by itself introduces a dependency on the encoding. If $$e_\min$$ is defined as "minimal exponent of the normal numbers" then, in my opinion, this definition hides that purpose of $$e_\min$$ but still implies subnormal numbers and their encoding. So it seams appropriate to either:
 * mention the purpose of $$e_\min$$ in the definition and that it can be ignored (or set to $$-\infty$$) when subnormals are not taken into account;
 * or remove $$e_\min$$ from the first definition completely and provide a less confusing Goldberg's one: $$\operatorname{ulp}(x) = b^{e-p+1}$$, moving information about handling of subnormals via $$e_\min$$ below the basic definition or to a footnote.

Personally, I am in favor of the latter, because (a) $$e_\min$$ seems like an overcomplicating detail unnecessary for a basic definition and (b) it introduces the said dependency on floating-point encoding. 86.102.214.55 (talk) 10:10, 8 April 2024 (UTC)

I further studied the source [Handbook of Floating-Point Arithmetic] which the article cites, and this first definition of ULP given in the article seems to be entirely incorrect.

First, the authors quote Goldberg's definition of ULP, which is $$b^{e-p+1}$$.

Then they introduce Definition 5, which they call "Goldberg's definition, extended to reals", which is the definition used in the Wikipedia article, stating that it is used "if we want to handle the subnormal numbers properly".

For simplicity here let not want to do that, and assume that $$b^e \leq x_i \leq x < x_{i+1} = b^{e+1}$$, where $$x_i$$ and $$x_{i+1}$$ are two adjacent floating-point numbers.

That is, by the definition of the authors and the Wikipedia article, $$\operatorname{ulp}(x) = b^{e+1-p}$$ which is the Harrison's ulp as opposed to the Goldberg's one. The Goldberg's ulp, which the cited handbook quotes, is: "if the floating-point number $$d.d\dots d\times b^e$$ is used to represent $$x$$, then it is in error by $$|d.d\dots d - (x/b^e)|b^{p-1}$$ units in the last place" [I changed the variables here to correspond to the Wikipedia article].

That is, the Goldberg's ulp, as opposed to the Harrison's ulp, depends on which floating-point number is chosen as the approximate value of $$x$$. Particularly, if approximate value of $$x$$ is $$x_{i+1} = b^{e+1}$$, then the difference between the definitions arise: in this case $$1\text{ ulp} = b^{e+2-p}$$ contrary to the Wikipedia article and Harrison's definition.

Indeed, by the Goldberg's definition, 1 ulp in this case equals $$\frac{x_{i+1} - t}{b^{e+1}}b^{p-1} = 1$$ for some $$t$$ which is one Goldberg's unit in the last place less than $$x_{i+1}$$. But this implies that $$1\text{ ulp} = x_{i+1} - t = b^{e+2-p}$$ which is $$b$$ times greater than the both the Harrison's definition and what the Wikipedia article (together with the cited book) states.

Given this, and my earlier comment, I suggest the following correction to the article:
 * move $$e_\min$$ out of the first definition to a footnote;
 * correct the first definition to "$$\operatorname{ulp}(x) = b^{e+1-p}$$, where $$e$$ is the exponent of the floating-point approximation chosen for $$x$$".

If there are no objections to these, I will correct the article as stated in the coming days.

Regards. 86.102.214.55 (talk) 13:02, 8 April 2024 (UTC)
 * First, $$e_\min$$ is a property of the floating-point system. It is defined at the representation level (Level 3 of IEEE 754), without the necessity to specify the encoding (Level 4).
 * Concerning Goldberg's paper, the subnormal range is ignored, as in a footnote, Goldberg says: "Numbers which are out of range in this fashion will not be considered until further notice."
 * Concerning $$\operatorname{ulp}(x) = b^{e+1-p}$$, this corresponds to Goldberg's ulp for the normal range. There are no such simple formulas for Harrison's ulp, where 2 cases need to be distinguished (whether x is or isn't a power of the radix).
 * One possibility would be to give a first definition for the normal range (also valid with an unbounded exponent range, where $$e_\min$$ does not exist, but that's purely theory), thus exactly corresponding to Goldberg's definition. And then give the more general definition for a floating-point system with or without subnormals (note that in practice, $$e_\min$$ exists whether the system has subnormals or not, and the general formula $$\operatorname{ulp}(x) = b^{\max \{ e, \, e_\min \} - p + 1}$$ remains valid in both cases).
 * Regards,
 * Vincent Lefèvre (talk) 13:50, 8 April 2024 (UTC)
 * Vincent Lefèvre (talk) 13:50, 8 April 2024 (UTC)