...
This code can result in a divide-by-zero error during the division of the signed operands sl1
and sl2
.
Code Block | ||
---|---|---|
| ||
signed long sl1, sl2, result;
/* Initialize sl1 and sl2 */
result = sl1 / sl2;
|
...
This compliant solution tests the suspect division operation to guarantee there is no possibility of divide-by-zero errors.
Code Block | ||
---|---|---|
| ||
signed long sl1, sl2, result;
/* Initialize sl1 and sl2 */
if ( (sl2 == 0) ) {
/* handle error condition */
}
else {
result = sl1 / sl2;
}
|
...
This code can result in a divide-by-zero error during the remainder operation on the signed operands sl1
and sl2
.
Code Block | ||
---|---|---|
| ||
signed long sl1, sl2, result;
/* Initialize sl1 and sl2 */
result = sl1 % sl2;
|
...
This compliant solution tests the suspect remainder operation to guarantee there is no possibility of a divide-by-zero error.
Code Block | ||
---|---|---|
| ||
signed long sl1, sl2, result;
/* Initialize sl1 and sl2 */
if ( (sl2 == 0 ) ) {
/* handle error condition */
}
else {
result = sl1 % sl2;
}
|
...
<ac:structured-macro ac:name="unmigrated-wiki-markup" ac:schema-version="1" ac:macro-id="4f1648c5885ba407-9f21e61d-4ba544aa-888bbb1c-4553773d8b30f45ed57773a9"><ac:plain-text-body><![CDATA[ | [[ISO/IEC 9899:1999 | AA. Bibliography#ISO/IEC 9899-1999]] | Section 6.5.5, "Multiplicative operators" | ]]></ac:plain-text-body></ac:structured-macro> |
<ac:structured-macro ac:name="unmigrated-wiki-markup" ac:schema-version="1" ac:macro-id="c27b0f7b64b94262-ad3e9207-4c3c4765-be809c0c-8e27da4372521a68df017608"><ac:plain-text-body><![CDATA[ | [[Seacord 05 | AA. Bibliography#Seacord 05]] | Chapter 5, "Integers" | ]]></ac:plain-text-body></ac:structured-macro> |
<ac:structured-macro ac:name="unmigrated-wiki-markup" ac:schema-version="1" ac:macro-id="36e280fdd78fe958-8275f9fa-42c8407e-9fb5a42b-3db155aecd78202a3985cd9e"><ac:plain-text-body><![CDATA[ | [[Warren 02 | AA. Bibliography#Warren 02]] | Chapter 2, "Basics" | ]]></ac:plain-text-body></ac:structured-macro> |
...