diff options
| author | Bruce Hill <bruce@bruce-hill.com> | 2025-04-07 01:17:02 -0400 |
|---|---|---|
| committer | Bruce Hill <bruce@bruce-hill.com> | 2025-04-07 01:17:02 -0400 |
| commit | f857f38f718fff586e373815a1bcad2701b4d983 (patch) | |
| tree | 29b3e367437099f39f6fc9a4e7d1dd2f177afb59 /src/stdlib/bytes.h | |
| parent | fb4e4cef1382a5e37d99ccb8e97fe1d2a8cd7e93 (diff) | |
Add `is_between()` for various types
Diffstat (limited to 'src/stdlib/bytes.h')
| -rw-r--r-- | src/stdlib/bytes.h | 3 |
1 files changed, 3 insertions, 0 deletions
diff --git a/src/stdlib/bytes.h b/src/stdlib/bytes.h index f875e7cb..2794d1d9 100644 --- a/src/stdlib/bytes.h +++ b/src/stdlib/bytes.h @@ -22,6 +22,9 @@ Byte_t Byte$from_int16(int16_t i, bool truncate); Closure_t Byte$to(Byte_t first, Byte_t last, OptionalInt8_t step); MACROLIKE Byte_t Byte$from_int8(int8_t i) { return (Byte_t)i; } MACROLIKE Byte_t Byte$from_bool(bool b) { return (Byte_t)b; } +MACROLIKE CONSTFUNC bool Byte$is_between(const Byte_t x, const Byte_t low, const Byte_t high) { + return low <= x && x <= high; +} extern const Byte_t Byte$min; extern const Byte_t Byte$max; |
