Re: converting single to integer
- From: dpb <none@xxxxxxx>
- Date: Wed, 19 Sep 2007 15:10:31 -0500
dpb wrote:
Rick Rothstein (MVP - VB) wrote: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?
Yes, memcopy is precisely the former, not the latter -- it simply moves the bits from one contiguous position in memory to another without regard for any specific interpretation of what either the source or destination memory may have.
Okay, given this, of what possible use is it (as it would apply to the OP's original question)?
Well, (this is assuming I understood the question) I'm guessing it's something like he read an array that had as its first value the number of entries. I'm also guessing he got that from some non-VB code and was trying to do a straight translation...
Of course, if that were the actual case, it would be simpler to Get the first Long into an integer variable and then Get the actual array size in an appropriately-sized array.
I've also seen (and used) such tricks played with custom-built databases and similar, particularly in older FORTRAN where it was a prime way to use EQUIVALENCE to allow a particular value in memory to be interpreted as either REAL or INTEGER depending on context.
So, overall I don't know how it actually fits into OP's desired usage, but it's best guess I got as to why would want to do so... :)
I guess another use would be to simply be able to examine the contents of a FP variable in a bit-pattern mode if were trying to write a utility exploring IEEE floating point representation or somesuch...
--
.
- 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
- From: David Kerber
- Re: converting single to integer
- From: dpb
- Re: converting single to integer
- From: Rick Rothstein \(MVP - VB\)
- Re: converting single to integer
- From: dpb
- Re: converting single to integer
- Prev by Date: Re: vbYesNo tab order ?
- Next by Date: Re: VB Array Structures
- Previous by thread: Re: converting single to integer
- Next by thread: Re: converting single to integer
- Index(es):
Relevant Pages
|