Example #1
0
int main() {

	/* union used to avoid conversion */
	union float_or_int { 
		float f; 
		int i; 
	} number;

	int j;

	/* echo and inspect array entries */
	printf( "floating point numbers to inspect and count\n" );

	for( j = 0; a[j] != 0.0; j++ ) {
		number.f = a[j];
		printf( "  %11g (hex representation = 0x%08x)\n", 
		number.f, number.i );
		count[ trailing_zeros( number.i ) ]++;
	}

	/* print frequency results */
	printf( "\nnumber of trailing zeros in float fractions\n" );
	printf( "  #0 - count\n" );

	for( j = 23; j >= 0; j-- ) {
		printf( "  %2d - %2d\n", j, count[j] );
	}

return 0;
}
Example #2
0
int main(int argc, char **argv)
{
	if (argc > 1)
		printf("# of trailing_zeros: %d\n",
				trailing_zeros(strtol(argv[1], NULL, 0)));
	else
		printf("Need argument\n");

	return 0;
}