.\" Copyright 2026 Andrew V.Kosteltsev (kx@radix-linux.su) .\" .\" .TH ibits_len 3 "September 14, 2026" "libmpu" "LibMPU Programmer's Manual" .SH NAME \fBibits_len\fP \- bit length of an unsigned integer .SH SYNOPSIS .nf .B #include .PP .BI "int ibits_len( mpu_int *" a ", int " nb " );" .fi .SH DESCRIPTION The \fBibits_len()\fP function returns the number of significant bits required to represent the unsigned integer located at address \fBa\fP. For a nonzero value this is the position of the most significant set bit, counting the least significant bit as position 1. For zero, the function returns 0. .PP The memory contents at address \fBa\fP are not changed. The \fBnb\fP parameter determines the size of the operand, in bytes, and should be one of the integer sizes defined by \fBlibmpu.h\fP (for example, \fBNB_I8\fP, \fBNB_I16\fP, ..., \fBNB_I65536\fP). .PP The function does not change the integer operation flags. .sp .SH EXAMPLES .nf .sp #include #include int main( void ) { mpu_int1024_t a; int nb = NB_I1024; __mpu_init(); iatoui( a, "89000000000000", nb ); printf( "nbits = %d;\\n", ibits_len( a, nb ) ); /* nbits = 47; */ __mpu_free_context(); return( 0 ); } .fi .sp .SH SEE ALSO .BR _int_digs(3), .BR libmpu(7).