Re: converting single to integer



In article <fcop1j$bin$2@xxxxxxxx>, none@xxxxxxx says...
David Kerber wrote:
In article <OitxKgW#HHA.980@xxxxxxxxxxxxxxxxxxxx>,
rickNOSPAMnews@xxxxxxxxxxxxxxxxx says...
...

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.

If by "different value" you mean a differing internal representation for
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.

--
Remove the ns_ from if replying by e-mail (but keep posts in the
newsgroups if possible).
.



Relevant Pages

  • Re: converting single to integer
    ... If by "different value" you mean a differing internal representation for the same numerical value... ... and interpret it as a 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. ... 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, 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. ...
    (microsoft.public.vb.general.discussion)
  • Re: FAQ 6.9 What is "/o" really for?
    ... Precompilation of the pattern into an internal representation at the moment of qravoids a need to recompile the pattern every time a match "/$pat/" is attempted. ... (Perl has many other internal optimizations, but none would be triggered in the above example if we did not use ... I don't understand why /o makes a different in cases form2 and form5 if the pattern has already been compiled. ...
    (comp.lang.perl.misc)
  • Re: Definition of NULL
    ... > The internal representation (bit pattern) of a NULL is not specified. ... > must be true if p contains a NULL pointer. ... C FAQ. ...
    (comp.lang.c)
  • Re: Extracting patterned filenames from [glob] without a loop - possible?
    ... > according to the original pattern of only looking for files with this ... impossible to create a precise matching pattern in the [regexp] ... So that leaves just matching the file name. ... I interpret "_" as a literal underscore you want in the file name. ...
    (comp.lang.tcl)
  • Re: converting single to integer
    ... and interpret it as a Single, ... sincerely doubt it would return the same value as that bit pattern ... any integer requiring over that many bits for representation will ... lose precision if cast to a Single. ...
    (microsoft.public.vb.general.discussion)