C
CBFalconer
Keith said:That's nice. Now would you care to answer the question that I
actually asked?
It's obviously NO. An fp-object-value came from a fp-object.
Keith said:That's nice. Now would you care to answer the question that I
actually asked?
Richard said:CBFalconer said:Replace fp-value with real value, and the answer is YES.
The problem being that, with vanishingly few[1] exceptions, you
can't introduce a real value into a C program.
[1] Vanishingly few in comparison to the total number of reals.
Richard Heathfield said:Ike Naar said:
Terry Pratchett has commented on the relationship between
exclamation mark density and sanity.
Ben said:.... snip ...
I can't parse this at all. Is ymin not the largest real that
(theoretically) converts to x (y's predecessor)? Is EPSILON not
1/8 in your example system? Does "(y-epsilon)==(y*(1-EPSILON))"
use real or floating point operations (i.e. how much does the
last "these" refer to?
I tried to complete your example by you disagree with my result.
You tell us. Give x = 1.0 what are y, xmax and ymin in your
3-bit floating point example? It sounds as if you think this
idea is a simple one, so show us how simple it is by showing us
a what a few numbers represent (i.e,. what ranges) in your
simple example system.
---- end requote -------- requote ----
Lets see if I can leap over the confusion. Consider a system with
a 4 bit significand, and an 8 bit exponent. The exponent uses the
value 128 to signify times 2 to the 0th power. We suppress the
msbit in the significand and replace it with a sign bit. The
significand can hold 0 through 15. Thus:
Exponent Significand Means
128 0 = 0x0 1.0
128 1 = 0x1 1.0 + 1/8
128 2 = 0x2 1.0 + 1/4
128 4 = 0x4 1.0 + 1/2
128 7 = 0x7 1.0 + 7/8
128 8 = 0x8 -1.0 /* the sign bit appeared */
128 9 = 0x9 -1.0 - 1/8
128 10 = 0xa -1.0 - 1/4
128 12 = 0xc -1.0 - 1/2
128 15 = 0xf -1.0 - 7/8
if we raise the exponent by 1, we double the value in Means. If we
lower it by one, we halve the values in Means. I hope we are
agreed so far.
Now, what is the EPSILON involved here. Obviously if we add 1/8 to
1.0, we get the next value. But that doesn't consider the rounding
done by the hardware. We only need to add 1/16 to get that
effect. What is the value 1/16 in that system?
127 0 1/2
126 0 1/4
125 0 1/8
124 0 1/16 /* Aha */
1.0 + 1/16 will round up to 1.0 + 1/8. /* assume usual rounding */
What does this result look like? See above. Only one least
significant bit is changed. So we have found EPSILON to be 1/16,
and the result from nextafter would be 1.0 + 1/8.
Keith said:Please humor us anyway.
For now, a concrete example for your implementation will suffice.
Keith said:I honestly couldn't tell that you were joking.
You've been making numerous technical claims here that are, in
my opinion, not only incorrect but nonsensical. It's difficult
to distinguish between your nonsensical claims that you actually
believe and the ones that are meant to be humorous.
(If it turns out that this whole thing was your idea of a joke,
I will not be happy.)
Keith said:Are you *trying* to confuse the issue?
So, are both statements true?
Keith said:And you concluded from this that actual released
implementations are likely to be buggy how, exactly? Never
mind, I probably don't want to know.
Keith said:.... snip ...
I think your knowledge of fp systems is flawed, or at least
inconsistent with the C standard.
I've asked you this before but ... if your model is valid, then it
is a set of fundamental facts about floating-point numbers, facts
without which it is difficult or impossible to understand what FP
numbers really mean. Why then does the standard say so little
about these ranges of yours? If you had written C99 5.2.4.2.2, I
presume the word "range" would have appeard many times; why does
the standard use the word "range" only in reference to the full
range of a floating-point type, never to the range represented by
a single value?
CBFalconer said:Yes it does (usually). That is not a static value. The C system
has generated initialization code, that is executed on the entry to
the function, which reserves the space and initializes it. It MAY
have generated a fp-constant to be jammed in, but it more likely
generates a 1.0 and a 3.0 and tells the system to perform a divide
and store the result. When the 1 and the 3 exist, and not the
fp-value, you have the actual one-third real value indicated.
After the storage, it has been approximated.
C (non-static) initialized objects are quirky. They really consist
of calls to some routine or other to set the value in the object,
and maybe to calculate it. That's why they can be fairly complex.
The code is still there.
CBFalconer said:Keith said:[snip]CBFalconer said:Keith Thompson wrote:
... snip ...
The function has a defined input and output. The input defines
the real value 1/3. The output is the fp-value representing that.
No, the inputs are the int value 1 and the int value 3.
No. I can put them in a structure:
But in the code you posted you didn't put them in a structure, so
what's your point?
But the only purpose of any code was to illustrate ways of
specifying EXACTLY the real 1/3.
And thus to illustrate the rough
point at which that specification was converted into an fp-object
approximated value. If you had worked with transcendentals
generating the specification would have been harder.![]()
CBFalconer said:Alright, this has already gone over the calculation of xmax and
then generating y. Summarized:
x = 1.0
xmax = 1.0 + 1/16 (= x + EPSILON = x*(1+EPSILON) = x*(1+1/16)
y = 1.0 + 1/8
now we calculate ymin by using y*(1-EPSILON). Substute the value
of y:
ymin = (1.0+1/8)*(1-1/16)
This is NOT the same as xmax. It differs by 1/8 * 1/16.
I hope this answers your question.
CBFalconer said:I wish you had quoted my original. I spent about 15 minutes
looking for it here, and didn't find it. ...
found it, much nearer
than I was looking. (I have 343 messages in this thread).
---- end requote ----
Alright, this has already gone over the calculation of xmax and
then generating y. Summarized:
x = 1.0
xmax = 1.0 + 1/16 (= x + EPSILON = x*(1+EPSILON) = x*(1+1/16)
y = 1.0 + 1/8
now we calculate ymin by using y*(1-EPSILON). Substute the value
of y:
ymin = (1.0+1/8)*(1-1/16)
This is NOT the same as xmax. It differs by 1/8 * 1/16.
I hope this answers your question.
CBFalconer said:Now I am confused myself, so I better not answer. I think we are
getting mixed up in the 'real valued' and the 'fp-valued'
epsilons. The real one changes with each different fp-object-value
(the x*(1+EPSILON) factor, as compared to x+epsilon, where epsilon
is the real valued one. I am just mulling here, not trying to give
a direct answer.
[...]CBFalconer said:No, I said I expected them to be more likely to show up.
CBFalconer said:I don't. I think the C standard is incomplete in this regard.
When you say 'floating-point numbers' above, are you talking about
real values, or values that the fp-object can hold and spit back?
I don't think it matters too much there, but it illustrates the
things that need caution.
I have to be guessing about the why. Because it does get
complicated by the use of real real values, and those
approximations held by the fp-object, etc. For most operations it
all doesn't matter - the fp-object accuracy is more than
sufficient. I'm sure I still have some things mixed up. But there
are times when the 'range' shows up in spades - differences between
nearly equal fp-objects stand out. That sort of thing strongly
affects matrix inversion.
Richard Heathfield said:Fine. Please show me how to specify the (positive) square root of 2
to a C program. Not an approximation, please, but the *exact*
number, in its full, real, and indeed irrational glory.
CBFalconer said:Certainly it did. It handed the integers 1 and 3 to a divide
routine.
The divide routine labored mightily, but failed to complete the
division, so it returned the nearest value it could calculate.
CBFalconer said:People do not seem to appreciate my attempt to inject a touch of
humor/humour.
Richard said:Can anyone hazard a guess how many time Chucky has proudly mentioned
"Epsilon" as it were somehow making him seem big and clever?
Want to reply to this thread or ask your own question?
You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.