Re: storing an integer in a double precision

Lynn McGuire <lmc@xxxxxxxxxx> wrote:

Just a lack of understanding of conversion between integers and
double precision on my part. Back when we were primarily single
precision, we had to be very careful, using "ii = xx + 0.1" to
ensure that we did not loose the whole number value of a
incomplete conversion of 12,000 which was stored in the float
as 11.9999.

I have noticed lately that I have gotten lazy since we converted
the entire program to double precision and don't add the 0.1
conversion factor anymore as we don't seem to need it anymore.

You won't need it in single precision either. I had a co-worker who used
to do that, allegedly because of some bad experience in a compiler from
long ago. I never did figure out what system that would have been from,
but we are talking before f66. I'm also not at all sure that it ever
actually was a problem; I strongly suspect that he put it there just in
case, without ever having seen a problem.

As noted elsewhere, the standard doesn't actually guarantee this. But
you won't find a compiler that it fails on in either single or double
precision. If you manage to belie me by finding one, I'd be very
interested in being shown the error of that particular one of my ways.

(Finding one doesn't mean recalling what someone thinks was the behavior
of some compiler from 40 years ago; I'm talking about actually finding
one running somewhere. I'll avoid saying who this parenthetical comment
is aimed at. :-))

Richard Maine | Good judgment comes from experience;
email: last name at domain . net | experience comes from bad judgment.
domain: summertriangle | -- Mark Twain