Array Indexing
Lionello Lunesu
lio at lunesu.remove.com
Wed Apr 26 00:16:31 PDT 2006
Frits van Bommel wrote:
> DigitalMars D compiler News wrote:
>> I have another problem (I'm kinda a newbie in D, I come from a .NET
>> background) when I index an array with a byte. I have this function
>> that returns a byte I use for index on an array. The thing is that
>> whan that byte value is over 0x7F where it would be negative if it was
>> a char the runtime raises an array bounds exception, I know a
>> workaround and that is to and the value with 0xFF but I shouldn't have
>> to (and if I perform an explicit cast it doesn't help it) since it is
>> already a byte. Anyone knows if this is correct behavior?
>
> 'byte' is a signed 8-bit integer. Try ubyte instead, that's the unsigned
> variant.
This one has also bitten me a couple of times. "byte" just feels
unsigned to me. All the "byte"-like typedefs I've encountered in C were
always "unsigned char".
L.
More information about the Digitalmars-d
mailing list