Array Indexing

Frits van Bommel fvbommel at REMwOVExCAPSs.nl
Tue Apr 25 13:13:53 PDT 2006


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.



More information about the Digitalmars-d mailing list