check_range - 1Fr3aK2/Cub3d GitHub Wiki

📝 check_range

This function checks if a given integer is within the valid range of 0 to 255, inclusive.

⚙️ Parameters

Parameter Type Description
nb int The integer value to check.

🔁 Returns

Return value Description
bool Returns true if the integer is between 0 and 255 inclusive, otherwise returns false.

📖 Description

The check_range function validates whether a given integer falls within the range of 0 to 255. This is commonly used for checking values such as RGB color components, which must lie within this range.

  • If nb is less than 0 or greater than 255, the function returns false.
  • Otherwise, the function returns true.

💡 Example Usage

int value = 128;

if (check_range(value)) {
    printf("Value is within range.\n");
} else {
    printf("Value is out of range.\n");
}