Re: converting single to integer
- From: dpb <none@xxxxxxx>
- Date: Wed, 19 Sep 2007 08:19:54 -0500
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 for the same numerical value...What is the difference between storing a Single in an Integer and "casting" a Single to an Integer... isn't the end result the same... an Integer?They're both integers, but have different values.
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).
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
http://docs.sun.com/source/806-3568/ncg_goldberg.html
--
--
.
- Follow-Ups:
- Re: converting single to integer
- From: David Kerber
- 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
- Prev by Date: Re: install files in one EXE
- Next by Date: Re: XP SP2 command line trouble - update
- Previous by thread: Re: converting single to integer
- Next by thread: Re: converting single to integer
- Index(es):
Relevant Pages
|