value_min_bits
minbits = value_min_bits(123,8); // == 1
minbits = value_min_bits(345,16); // == 1
minbits = value_min_bits(6789,1); // == 13
- value_min_bits(n,size)
- Returns the smallest number of words of a given size that can be used to store a given value.
COPY/// value_min_bits(n,size)
//
// Returns the smallest number of words of a given
// size that can be used to store a given value.
//
// n value, integer
// size word size, integer
//
/// gmlscripts.pro/license
{
return ceil(floor(logn(2, argument0) + 1) / argument1);
}
Contributors: Leif902, xot
GitHub: View · Commits · Blame · Raw