jcmp: My image compression format (w/ wavelets)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
This repo is archived. You can view files and clone it, but cannot push or open issues/pull-requests.
 
 
 
 

24 lines
516 B

#pragma once
#include <string>
inline bool is_pow_of_two(int n){
return (n & (n - 1)) == 0;
}
inline std::string human_string(int n){
static const std::string names [] = {"", "K", "M", "G"};
int i = 0;
while(n > 1000 && i < sizeof(names)){
n /= 1000;
++i;
}
return std::to_string(n) + names[i];
}
inline std::string field(std::string const & str){
const int length = 12;
if(str.size() > length) return str + ":\t";
auto add = length - str.size();
return str + ":" + std::string(add, ' ') + "\t";
}