Skip to content

IS_HEX macro

Douglas Lyman edited this page Nov 28, 2022 · 1 revision

Checks if a character is a base-16 digit.

Syntax

#define IS_HEX(c) (IS_DIGIT(c) || (IN_RANGE(c, 'A', 'F') || IN_RANGE(c, 'a', 'f')))
BOOL IS_HEX(char | wchar_t c);

Parameters

c
A char or wchar_t character.

Returns

A BOOL that determines whether the character is a base-16 digit or not.

Remarks

This macro only compares single characters and not entire strings. Passing a pointer to a string will not work.

Example

#include "Definitions.h"

int main() {
    IS_HEX('a'); // Resolves to true.
    IS_HEX('D'); // Resolves to true.
    IS_HEX(L'6'); // Resolves to true.
    IS_HEX('g'); // Non hex digit, always resolves to false.
    IS_HEX("A1B2C3"); // Error: Cannot compare entire string.
}

Requirements

Header Definitions.h
Assembly None