fix bytes stuff - STILL NEED TO FIX TESTS

This commit is contained in:
askiiart 2025-01-15 10:35:42 -06:00
parent 7111192081
commit 9fac0f3667
Signed by untrusted user who does not match committer: askiiart
GPG key ID: 6A32977DAF31746A
3 changed files with 31 additions and 16 deletions

View file

@ -135,3 +135,23 @@ pub fn char_length(base: u32) -> u32 {
}
return u32::MAX;
}
pub mod bytes {
/// Returns the minimum catspeak words per character needed for this base for bytes
///
/// ```
/// use cat2text::core::bytes::char_length;
///
/// let base = 16;
/// assert_eq!(char_length(base), 2)
/// ```
pub fn char_length(base: u32) -> u32 {
for i in 1..base + 1 {
let num = base.pow(i);
if num > 255 {
return i;
}
}
return u32::MAX;
}
}