digit_value
Description:
Determines the numeric value of a character as a decimal digit.
If the character is not a decimal digit according to [func@GLib.ascii_isdigit], `-1` is returned.
Differs from [func@GLib.unichar_digit_value] because it takes a char, so there's no worry about sign extension if characters are signed.
Example: Determine the character as a decimal digit:
public static int main (string[] args) {
// Output: ``'0', '1', '2', '3', '4', '5', '6', '7', '8', '9', ``
for (int i = 0; i <= 255; i++) {
if (((char) i).digit_value () >= 0) {
print ("'%c', ", (char) i);
}
}
print ("\n");
return 0;
}
valac --pkg glib-2.0 char.digit_value.vala
Parameters:
c |
an ASCII character |
Returns:
the numerical value of |