Categories:
.NET (357)
C (330)
C++ (183)
CSS (84)
DBA (2)
General (7)
HTML (4)
Java (574)
JavaScript (106)
JSP (66)
Oracle (114)
Perl (46)
Perl (1)
PHP (1)
PL/SQL (1)
RSS (51)
Software QA (13)
SQL Server (1)
Windows (1)
XHTML (173)
Other Resources:
How can I ensure that integer arithmetic doesnt overflow?
How can I ensure that integer arithmetic doesnt overflow?
✍: Guest
The usual approach is to test the operands against the limits in the header file <limits.h> before doing the operation. For example, here is a ``careful'' addition function:
int
chkadd(int a, int b)
{
if(INT_MAX - b < a) {
fputs("int overflow\n", stderr);
return INT_MAX;
}
return a + b;
}
2015-03-04, 1800👍, 0💬
Popular Posts:
How do we access attributes using “XmlReader”? Below snippets shows the way to access attributes. Fi...
How To Dump the Contents of a Directory into an Array? - PHP Script Tips - Working with Directoris a...
How was XML handled during COM times? During COM it was done by using MSXML 4.0. So old languages li...
What does XmlValidatingReader class do? XmlTextReader class does not validate the contents of an XML...
How To Create an Array in PL/SQL? - Oracle DBA FAQ - Introduction to PL/SQL If you want create an ar...