
Patrick B. answered 06/10/20
Math and computer tutor/teacher
That's going to lock up your machine....
There is no guarantee you are going to get an exact binary representation of a decimal fraction
Alyssa R.
asked 06/10/20001 unsigned int bitCount (int value) {
002 unsigned int count = 0;
003 while (value > 0) { / / until all bits are zero
004 if ( ( value & 1) == 1) { / / check lower bit
005 count++;
006 }
007 value >> 1; / / shift bits, removing lower bit
008 }
009 return count;
010 }
Patrick B. answered 06/10/20
Math and computer tutor/teacher
That's going to lock up your machine....
There is no guarantee you are going to get an exact binary representation of a decimal fraction
Get a free answer to a quick problem.
Most questions answered within 4 hours.
Choose an expert and meet online. No packages or subscriptions, pay only for the time you need.