At 2:29 PM -0800 3/22/1999, Michael S. Davis wrote:
>Assume fixed length record (all strings same length).
>Record:
>|<--string2-->|<-double1->|<-double2->|<-string2->| just as an example
>^
>|____ pointer to record data: UInt dataPtr;
>
>Can I just reference these like:
>
>if( *(dataPtr+OffsetToDouble1) < *(dataPtr+OffsetToDouble2) )
>{
> return -1;
>}
>
>Can I do something like this? I think you get my drift. If not
>what is the correct way to compare two doubles within a Record, without
>copying them to another location.
If you declare your record format as a struct, the compiler will add a pad byte after
string2 if necessary to put double1 at an even offset within the record. In this case,
you can compare in place by casting the record pointers into struct pointers. OTOH, if
you compress and decompress the data yourself, avoiding the padding, you'll have to
use MemMove to get the doubles to be at even addresses before you can compare them. In
this case, you should rearrange your record format so the doubles are at the
beginning. This should allow you to avoid the MemMoves. I have this on my own to-do
list for the app I'm working on.
-
Danny Epstein * mailto:[EMAIL PROTECTED]
Applied Thought Corporation * http://www.appliedthought.com
Flytrap for PalmOS * http://www.appliedthought.com/flytrap