> Does MemCmp not work as documented?
>
> Int rv;
> rv = MemCmp("01L", "02L", 3); <- rv = 255 after the call
> rv = MemCmp("02L", "01L", 3); <- rv = 1 after the call
>
> The documentation claims that it returns
> + if r1 > r2
> - if r1 < r2
> 0 if r1 = r2
>
> One of the MemCmp I tried should have returned < 0, what's up with that?
> I take it that it is doing byte-wise comparisons and rv is some difference
> of the first byte that doesn't match, I mean I guess I could write a
> "MemCmp" that does it the way I think it should, but I'd like to
> straighten out what I'm missing.
the first call should return -1. it all depends on the data type
that you are storing the result into. are you sure you are using
an "Int" to store the result?
if you are saying something like this:
Byte rv = MemCmp("01L", "02L", 3);
the result of MemCmp will return -1 (which is 1111111111111..) and
the value of -1 is stored in a byte memory location. Being a byte,
it is UNSIGNED - which means -1 will end up being 255.
SByte rv = MemCmp("01L", "02L", 3)
this code should put -1 in the variable "rv" - as it is a signed
data type. if your code is as shown above.. then it must be an
error in MemCmp.
check the data type.. this might be the problem.
cheers.
az.
--
Aaron Ardiri
Lecturer http://www.hig.se/~ardiri/
University-College i G�vle mailto:[EMAIL PROTECTED]
SE 801 76 G�vle SWEDEN
Tel: +46 26 64 87 38 Fax: +46 26 64 87 88
Mob: +46 70 656 1143 A/H: +46 26 10 16 11