3 ms·
It depends on dialect, but usually variables defaulted to float. I think his code would be OK on arrays that'd fit in 64K (and it'd fail by loss of precision ra
by abecedarius 11y ago
It depends on dialect, but usually variables defaulted to float. I think his code would be OK on arrays that'd fit in 64K (and it'd fail by loss of precision rather than overflow).
FWIW when I coded binary search back in the elder days I checked my C against Bentley's pseudocode but took care about overflow; I didn't judge this difference a bug in the pseudocode, but the sort of consideration necessary in rendering it to C. (Although I was being more careful than usual.) Since this was before the net or open source were part of professional life I didn't get to see other renditions to find out they were wrong.
- im3w1l 11y agoHe uses the cint which forces to int. Ninjaedit: cint is used for the midpoint, and is then assigned to either the upper or lower limit. After 2 or more iterations, both upper and lower limits can be ints.
- abecedarius 11y agoAfter the sum and division.