Re: whole number constants
- From: nospam@xxxxxxxxxxxxx (Richard Maine)
- Date: Mon, 21 Jul 2008 16:38:16 -0700
<dancerchris@xxxxxxxxxxxxx> wrote:
Do compilers use the same value for multiple
use of an integer in an equation of specified kind
I can't parse that question... and I think that is exactly part of the
problem. I think you are confusing multiple concepts. Namely...
There is no such thing as "an equation of a specified kind". Kind is not
a property of a whole equation. That's actually important and
occasionally confuses people. Each individual entity in an expression
has a type and kind, as does each operation result.
"Same value for mutiple use of an integer". I think I know what you are
asking there, but I'm having to guess, as the words don't quite parse.
There is one variant of the question that is quite subtle... but that
variant doesn't apply to integers. Repeat after me, small integer values
are exact.
it seems to me that label 100 is using a true constant such that the
numerical value out to the machine level (past kind dp) is consistant
in the equation (i.e. is copied from the storage register completely,
not just the significant digits).
Sorry, but just plain *NO*. That is not so. There are so many thing
wrong here, it is hard to list them.
There is no such thing as a "true constant." A constant of a particular
kind is of that kind. There is no concept of a constant that is of a
given kind, but actually has extra bits. Sorry, but there just isn't. I
can pretty much guarantee that if you are about to use this term in a
sentence, then the sentence is going to be wrong. I pretty much don't
have to read th erest of the sentence (but I did).
Also, I don't know what distinction this is that you are making between
"machine level" and the real kind. Except in the rare case of software
floating point, the machine representation *IS* that of the kind in
question. The kind facility maps onto the representations that the
machine supports. There aren't going to be "extra bits". There are
sometimes issues related to machine registers that can be wider than
some of the supported kinds, but that affects only temporary
calculations. That can give rise to complications, but not in the ways
you are looking. It certainly does not correlate in any way with the
syntax used for constants. And such things are never "copied from the
storage register completely," that being sort of the point of them.
Finally, I must note that you specifically asked about whole numbers. It
really does make a difference. Whole numbers of modest magnitude are
represented exactly in every kind on every compiler that you will ever
see. There aren't going to be any extra bits (except for zero bits) or
lost precision, no matter what kind you are talking about.
I think that label 200 does not
guarantee that, each instance of "1.0_dp" is assigned a value to the
dp accuracy (plus extraneous bits)
The value of 1.0 to dp accuracy is the same as its value to single
precision accuracy, which is the same as its value to any other
accuracy, including infinite accuracy. There aren't any other values it
will ever have. Don't generalize this to non-whole numbers, though.
I'm thinking you need to read Goldberg's "What Every Computer Scientist
Should Know About Floating-Point Arithmetic"
(<http://docs.sun.com/source/806-3568/ncg_goldberg.html>), but I'm
afraid your confusions might actually be more fundamental thanthat.
Still, reading it is unlikely to hurt.
--
Richard Maine | Good judgement comes from experience;
email: last name at domain . net | experience comes from bad judgement.
domain: summertriangle | -- Mark Twain
.
- Follow-Ups:
- Re: whole number constants
- From: Paul van Delst
- Re: whole number constants
- From: dancerchris
- Re: whole number constants
- References:
- whole number constants
- From: dancerchris
- Re: whole number constants
- From: *** Hendrickson
- Re: whole number constants
- From: dancerchris
- Re: whole number constants
- From: dancerchris
- Re: whole number constants
- From: Richard Maine
- Re: whole number constants
- From: dancerchris
- whole number constants
- Prev by Date: Re: internal file and namelist
- Next by Date: Re: internal file and namelist
- Previous by thread: Re: whole number constants
- Next by thread: Re: whole number constants
- Index(es):