5 use int.EuclideanDivision
16 use int.EuclideanDivision
19 function bcd_log (src : int) : int =
20 let dig1 = div src 1000 in
21 let r1 = mod src 1000 in
22 let dig2 = div r1 100 in
23 let r2 = mod r1 100 in
24 let dig3 = div r2 10 in
25 let dig4 = mod r2 10 in
26 dig1*4096 + dig2*256 + dig3*16 + dig4
29 let bcd_compute (src : uint16) : uint16
30 requires { 0 <= src <= 9999 }
31 ensures { uint16'int result = bcd_log (uint16'int src) }
33 let dig1 = src / 1000 in
34 let r1 = src % 1000 in
35 let dig2 = r1 / 100 in
39 dig1*4096 + dig2*256 + dig3*16 + dig4