Numeric access to char
Unknown W. Brackets
unknown at simplemachines.org
Tue Aug 22 07:11:48 PDT 2006
Do you want the numeric (integer/float) value of the string in a char?
For example, "1.0" => 1.0, and similar?
In other words, something similar to:
$x = (int) '324';
$y = intval('562');
$z = '324' + '9';
In PHP? If so, you want std.conv. The D code might look like this:
x = toInt(324);
y = toInt(562);
z = toInt(324) + toInt(9);
There's also toFloat, toDouble, toUint, etc. See:
Please note that an Exception is thrown if it cannot be converted, it
won't just be made 0. So, for example:
x = toInt(user_value);
x = 0;
x = int.max;
Or something like that.
If that's not what you want, a char is actually two numeric values -
much like in PHP. It is a length value, and a pointer. Bit shifting
these probably won't give you anything interesting.
> 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.
More information about the Digitalmars-d-learn