On Thu, Feb 28, 2008 at 08:13:49AM -0000, bhadson2001 wrote: > > unsigned char a; > a=255*20/10; > > it gives output 254 > > for > a=255*200/100; > > it gives output 111 > > why it gives different results. > > it there any logical relationship. The intermediate math is signed 16 bit integer. 255*200 = 51,000 which is -14,546. Divide by 100 = -145 = 111 unsigned. -- David Kelly N4HHE, dkelly@HiWAAY.net ======================================================================== Whom computers would destroy, they must first drive mad.
Message
Re: [AVR-Chat] C problem
2008-02-28 by David Kelly