Sort an integer array: Difference between revisions

m
→‎{{header|C}}: Subtraction is correct if no overflow. (No change to code.)
(added powerbasic)
m (→‎{{header|C}}: Subtraction is correct if no overflow. (No change to code.))
Line 144:
}</lang>
 
''Caution:'' An older version of <tt>intcmp()</tt> did <tt>return *a - *b</tt>. This wasis wrongonly becausecorrect when the subtraction candoes not overflow. Suppose that <tt>*a = 2000000000</tt> and <tt>*b = -2000000000</tt> on a machine with 32-bit <tt>int</tt>. The subtraction <tt>*a - *b</tt> would overflow to <tt>-294967296</tt>, and <tt>intcmp()</tt> would believe <tt>*a < *b</tt>, but the correct answer is <tt>*a > *b</tt>.
 
=={{header|C++}}==
Anonymous user