Skip to content

isHexadecimalDigit

gicking edited this page Feb 10, 2018 · 3 revisions

back to Command Reference / Characters

Description

Analyse if a char is an hexadecimal digit (A-F, 0-9). Returns true if thisChar contains an hexadecimal digit.

Inclusion

  • defined in misc.h
  • auto-loaded in main_general.h
  • no #define required

Syntax

isHexadecimalDigit(thisChar)

Parameters

  • input:

    • thisChar: character to test (char)
  • output:

    • none

Returns

  • true: if thisChar is an hexadecimal digit.
  • false: otherwise

Example Code

The below code reads a char from the terminal and checks for isHexadecimalDigit().

#include "main_general.h"
#include "uart1.h"
#include "putchar.h"

void setup() {

  // init UART, printf() and gets()
  UART1_begin(115200);
  putcharAttach(UART1_write);

} // setup

void loop() {

  if (UART1_available())
    if (isHexadecimalDigit(UART1_read()))
      printf("isHexadecimalDigit(x) = true\n");
    else
      printf("isHexadecimalDigit(x) = false\n");

}

Relevant Tutorial

  • tbd

See also

Clone this wiki locally