Numeric access to char[]

Peter Thomassen info at
Mon Aug 21 16:30:23 PDT 2006

nobody schrieb am Dienstag, 22. August 2006 00:54:
>> how is it possible to work on the numeric value of a char[]? I'm
>> interested in bit shifting and arithmetic operations on the numeric
>> value.
> I am pretty sure you can just treat a char as a ubyte. The char type is 8
> bits and unsigned. However if it makes it easier for you then you might
> try this:
>    int main(char[][] args)
>    {
>      ubyte[] num1 = cast(ubyte) args[0];
>    }

When casting to ubyte[], this works fine. But I actually meant the numeric
value of char[], not the one of char. Do I need to construct it from the
single chars, or can I, for example, right-shift a whole char[] by 1?


More information about the Digitalmars-d-learn mailing list