How could I convert binary to decimal in ocaml in the following, If I am representing binary numbers like the following 01 is [False; True] which equals 2? I want to write a method to return the double of the number in decimal form. For example in this case the method will take in [False; True] and return [False; False, True] which is 4.
+2
A:
To double a number, add a Zero in front of its binary representation.
let double n = False :: n ;;
Pascal Cuoq
2009-10-22 12:38:42
How could I return the integer representation of the list??
Polly Hollanger
2009-10-22 16:20:36
@Polly You can do it either with a recursive function you write yourself, or with `List.fold_left`.
Michael E
2009-11-24 22:41:53