Email: Password: Remember Me | Create Account (Free)

Back to Subject List

Old thread has been locked -- no new posts accepted in this thread
???
08/23/02 14:47
Read: times


 
#27825 - RE: problem solved! -- Maybe!
Hi Kenny,

One thing to keep in mind when using C is the way it handles variable promotion during calculations. In your example, your result=x*y might give you the wrong value because the multiplication will be done using integers, with the result promoted to long *after* the multiplication...so it would be trucated.

If you always know what your expected results are you can get away with this, since integer multiplication code is smaller and faster than long multiplication code.

But sometimes you have to do it the safe way, i.e., result = (long)x * (long)y;

Good luck,

Dennis

List of 6 messages in thread
TopicAuthorDate
multiplication and division in 8051            01/01/70 00:00      
RE: multiplication and division in 8051            01/01/70 00:00      
RE: multiplication and division in 8051            01/01/70 00:00      
RE: multiplication and division in 8051            01/01/70 00:00      
problem solved!            01/01/70 00:00      
RE: problem solved! -- Maybe!            01/01/70 00:00      

Back to Subject List