
3 Jul
2012
3 Jul
'12
9:21 a.m.
Am 02.07.2012 19:17, schrieb Bryan O'Sullivan:
It already surprised me that digitToInt accepted hex digits;
This indicates that digitToInt is broken anyway (or should be named hexDigitToInt). For the decimal case you would need to use "isDigit" anyway and then could use just "ord c - ord '0'" instead of "digitToInt". So a (more) total implementation of intToDigit could avoid some tests leaving it to the programmer to decide between speed and safety. Cheers Christian | c <= '9' = ord c - ord '0' | c >= 'a' = ord c - ord 'a' + 10 | otherwise = ord c - ord 'A' + 10