BinaryString() bytes in reverse order?

2 posts in this topic

blindwig 1

I'm working on optimizing a base64 conversion routine and I go the idea that I can use a BinaryString() function call instead of doing lots of Chr() functions. I was also hoping that I could use the int() and/or Number() functions instead of asc() functions.

First, I notice that BinaryString() puts the bytes in reverse order. This isn't a bug, as this is the way that the function is described in the manual. I'm just curious as to why it would do this - what's the purpose of reversing the bytes?

Second, why does the Number() function only consider the first byte of the BinaryString? The statment "Number(string(256*256*256*256))" works as expected, so obviously the Number() function is capable to handle numbers bigger than 8 bits?

And one more thing - BinaryString() always returns a string that is a multiple of 4. So the statement "StringLen(BinaryString(65))" evaluates to 4. Why is this? Agagin, this is not a bug, it is in the manual, but I just want to know why.