Re: converting single to integer



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...
...

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.

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).
.



Relevant Pages

  • Re: Reverse Engineering Parts
    ... There are several ways to build a common pattern. ... After the worn areas/diameters etc are rebuilt, pour a plaster cast and then use plastic to pour a reverse into the plaster cast, don't forget to use wax and/or parting spray. ... The concept is simple, to make a male pattern of a bear, get a block and take off everything that don't look like a bear. ... Other than machining skills, it is a matter of visualizing and understanding what isn't present during the material block stage and taking the block to a finished state. ...
    (alt.machines.cnc)
  • Re: Knitting: My head just exploded!
    ... Latvian slip, bavarian, sixty different ways to cast on, ... pattern library. ... I'm thinking of taking their needle felting class in January. ...
    (rec.crafts.textiles.needlework)
  • Re: Gingerbread men
    ... asked about an online pattern for them, ... Cast on 7 sts ... Break yarn leaving leg on needle. ...
    (rec.crafts.textiles.yarn)
  • Re: Knitting: My head just exploded!
    ... Latvian slip, bavarian, sixty different ways to cast on, ... pattern library. ... the most anal thing I do - I rewrite instructions. ...
    (rec.crafts.textiles.needlework)
  • Re: Knitting: My head just exploded!
    ... Latvian slip, bavarian, sixty different ways to cast on, ... pattern library. ... I'm getting something from a mag, or even a pattern book - I'll write the ...
    (rec.crafts.textiles.needlework)

Loading