20 |
let hexa_digit x = |
let hexa_digit x = |
21 |
if x >= 10 then Char.chr (Char.code 'A' + x - 10) |
if x >= 10 then Char.chr (Char.code 'A' + x - 10) |
22 |
else Char.chr (Char.code '0' + x) |
else Char.chr (Char.code '0' + x) |
23 |
|
|
24 |
|
let rec octal x = |
25 |
|
if x < 8 then x else (x mod 10) + 8 * (octal (x / 10)) |
26 |
|
|
27 |
|
let int_of_octal_string s = |
28 |
|
let l = String.length s in |
29 |
|
let octal_of_char c = |
30 |
|
int_of_char c - int_of_char '0' in |
31 |
|
let rec octal_aux acc i = |
32 |
|
if i < l then octal_aux (acc * 8 + (octal_of_char s.[i])) (i+1) |
33 |
|
else acc in |
34 |
|
octal_aux 0 0 |