aboutsummaryrefslogtreecommitdiff
path: root/src/stdlib/bytes.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/stdlib/bytes.c')
-rw-r--r--src/stdlib/bytes.c10
1 files changed, 7 insertions, 3 deletions
diff --git a/src/stdlib/bytes.c b/src/stdlib/bytes.c
index 4416d804..9874f222 100644
--- a/src/stdlib/bytes.c
+++ b/src/stdlib/bytes.c
@@ -25,12 +25,14 @@ PUREFUNC public Text_t Byte$as_text(const void *b, bool colorize, const TypeInfo
'\0',
};
Text_t text = Text$from_str(digits);
- if (colorize) text = Texts(Text("\x1b[35m"), text, Text("\x1b[m"));
+ if (colorize) text = Text$concat(Text("\x1b[35m"), text, Text("\x1b[m"));
return text;
}
public
-CONSTFUNC bool Byte$is_between(const Byte_t x, const Byte_t low, const Byte_t high) { return low <= x && x <= high; }
+CONSTFUNC bool Byte$is_between(const Byte_t x, const Byte_t low, const Byte_t high) {
+ return (low <= x && x <= high) || (high <= x && x <= low);
+}
public
OptionalByte_t Byte$parse(Text_t text, OptionalInt_t base, Text_t *remainder) {
@@ -67,7 +69,9 @@ public
bool Byte$get_bit(Byte_t x, Int_t bit_index) {
if (Int$compare_value(bit_index, I(1)) < 0) fail("Invalid bit index (expected 1 or higher): ", bit_index);
if (Int$compare_value(bit_index, I(8)) > 0)
- fail("Bit index is too large! There are only 8 bits in a byte, but index is: ", bit_index);
+ fail("Bit index is too large! There are only 8 bits in a byte, but index "
+ "is: ",
+ bit_index);
return ((x & (Byte_t)(1L << (Int64$from_int(bit_index, true) - 1L))) != 0);
}