Re: converting single to integer
- From: David Kerber <ns_dkerber@xxxxxxxxxxxxxxxxxxxxxxxxxxxxx>
- Date: Wed, 19 Sep 2007 09:46:26 -0400
In article <fcr7r2$3l8$1@xxxxxxxx>, none@xxxxxxx says...
David Kerber wrote:
In article <fcop1j$bin$2@xxxxxxxx>, none@xxxxxxx says...
David Kerber wrote:
In article <OitxKgW#HHA.980@xxxxxxxxxxxxxxxxxxxx>,...
rickNOSPAMnews@xxxxxxxxxxxxxxxxx says...
If by "different value" you mean a differing internal representation forWhat is the difference between storing a Single in an Integer and "casting"They're both integers, but have different values.
a Single to an Integer... isn't the end result the same... an Integer?
the same numerical value...
Are you sure about that? I don't know the internal representation of
the various types of numbers, but if you take the bit pattern:
00011010 11100001 00001111 10101010
and interpret it as a Single (assuming it represents a valid Single), I
sincerely doubt it would return the same value as that bit pattern
interpreted as an Integer, which is what you are doing when you use
memcopy to copy from a single to an integer. Or am I completely
misintrepreting the line of this discussion? If you use a Cast, then
you will get the same value, but a different internal bit pattern.
I think we're then talking past each other...yes, the internal bit
pattern isn't the same between the same integer stored in Single as
floating point as the same integer stored as a Long -- which is what I
said (and I gather what you meant although it seemed unclear to me as
written previously).
Yes, that's what I meant.
In IEEE-754 floating point, not all bit patterns are legal as floating
point representations so some valid integers aren't valid floats. And,
since there are only 23 bits reserved for the mantissa plus a "hidden"
bit, any integer requiring over that many bits for representation will
lose precision if cast to a Single. For a readable description of
floating point in general and the IEEE standard, see
So I guess we're saying the same thing, but in such different ways that
we can't understand each other <GGGG>. Like Americans and Brits: two
people divided by a common language :-)
I do have one question to clarify my knowledge, though: does the
memcopy command copy the raw bit pattern from one location to another,
or does it do an implicit cast? My understanding is that it copied bit-
for-bit, so taking a memory location that was defined as a single and
copying it to a location that was then interpreted as long would come up
with a different value than the original Single. Is that a correct
interpretation?
.....
--
Remove the ns_ from if replying by e-mail (but keep posts in the
newsgroups if possible).
.
- Follow-Ups:
- Re: converting single to integer
- From: Mike Williams
- Re: converting single to integer
- From: dpb
- Re: converting single to integer
- References:
- Re: converting single to integer
- From: Rick Rothstein \(MVP - VB\)
- Re: converting single to integer
- From: David Kerber
- Re: converting single to integer
- From: dpb
- Re: converting single to integer
- From: David Kerber
- Re: converting single to integer
- From: dpb
- Re: converting single to integer
- Prev by Date: Re: XP SP2 command line trouble - update
- Next by Date: Re: converting single to integer
- Previous by thread: Re: converting single to integer
- Next by thread: Re: converting single to integer
- Index(es):
Relevant Pages
|
Loading