Description

Analyze if a char is a hexadecimal digit (A-F, 0-9). Returns true if the input char contains a hexadecimal digit.

Syntax

Use the following function to evaluate a char variable:

isHexadecimalDigit(thisChar)

Parameters

The function admits the following parameter:

thisChar: char variable to evaluate. Allowed data types: char.

Returns

The function returns true if the evaluated input variable is a hexadecimal digit.

Example Code

char myChar = 'F';  // try with 'G' for a non hex digit

void setup() {
  Serial.begin(9600);

  if (isHexadecimalDigit(myChar)) {  // tests if myChar is an hexadecimal digit
    Serial.println("The character is an hexadecimal digit");
  } else {
    Serial.println("The character is not an hexadecimal digit");
  }
}

void loop() {
}

See also