How we increment a value without using operator'+'.q2?what is single tone class. thanks

Questions by gudia

Showing Answers 1 - 4 of 4 Answers

Ahmet Ali Akkas

  • Jan 17th, 2007
 

a = ~a; a--;

  Was this answer useful?  Yes

ujjal

  • Jan 28th, 2007
 

The solution given by Ahmed needs change it will not give the correct output. if a=10 then ouput will be -12 as per the problem solun, hence output is wrong. (if i am worng please correct me ). Solution will be as follows :

int a=10
(suppose it values is 10);
a = ~a;
printf("%d",-a);
OUTPUT will be 11;

  Was this answer useful?  Yes

Hemendra Jain

  • Mar 27th, 2007
 

Consider data is in HEX. Right shift the data till ‘0’ is encountered AND increment the count.
The position where ‘0’ is encountered , change it to ‘1’ and all bits to ‘0’ for all the LSB bits shifted
For e.g Data = 0x 07 = 0000 0111Here, 4th bit from the LSB is ‘0’So, 4th bit will become ‘1’And all the LSB bits before this will become ‘0’

  Was this answer useful?  Yes

Give your answer:

If you think the above answer is not correct, Please select a reason and add your answer below.