laoo Posted December 18, 2019 Share Posted December 18, 2019 (edited) 4 hours ago, karri said: The reason is that off is defined as unsigned char. Sure, the low level details are clear. But the real question is why it behaves that way. I'm not sure which standard cc65 tries to follow, but modern implementations in this scenario follow the rules of usual arithmetic conversions and integer promotions (§6.3.1.1): Applying these ruses the "180-hoff" expression should have been calculated on ints and the result would be as expected. That said and after some thinking I'm leaning towards conclusion that it's indeed not a bug but conscious decision to perform operations on smaller types due to performance reasons with accordance to §5.1.2.3: ...although in somewhat clumsy way. So... if in doubts: use explicit casts and parentheses Edited December 18, 2019 by laoo 1 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.