Forums
New posts
Search forums
Members
Current visitors
Log in
Register
What's new
Search
Search
Search titles only
By:
New posts
Search forums
Menu
Log in
Register
Install the app
Install
Forums
Archive
Archive
C Programming
unsigned short addition/subtraction overflow
JavaScript is disabled. For a better experience, please enable JavaScript in your browser before proceeding.
Reply to thread
Message
[QUOTE="Old Wolf, post: 1693646"] If we have two "unsigned short"s, values 65535 and 3 respectively, Just to make sure this is absolutely clear in my mind: You are saying that the type of the expression (unsigned short)65535 + (unsigned short)3 could be something other than "unsigned short" ? Also, if we have unsigned short a = 65535, b = 3; then could the type of (a + b) not be "unsigned short" ? This would be relevant to templates and/or function overloading, eg. void f(unsigned int t) { /*...*/ } void f(signed int t} { /*...*/ } and you went: f((unsigned short)65535 + (unsigned short) 3) or: f(65535u + 3u) or, with the above declarations: f(a+b) // might not even know till runtime Finally, I had been taught that "65535u" means (unsigned int)65535 which is a whole different kettle of fish to (unsigned short)65535. Is this correct? [/QUOTE]
Verification
Post reply
Forums
Archive
Archive
C Programming
unsigned short addition/subtraction overflow
Top