/[mldonkey]/mldonkey/src/utils/lib/misc.ml
ViewVC logotype

Diff of /mldonkey/src/utils/lib/misc.ml

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.2 by spiralvoice, Tue Jul 5 12:26:40 2005 UTC revision 1.3 by spiralvoice, Tue Jul 12 23:08:57 2005 UTC
# Line 32  let int_of_octal_string s = Line 32  let int_of_octal_string s =
32      if i < l then octal_aux (acc * 8 + (octal_of_char s.[i])) (i+1)      if i < l then octal_aux (acc * 8 + (octal_of_char s.[i])) (i+1)
33      else acc in      else acc in
34    octal_aux 0 0    octal_aux 0 0
35    
36    (* taken from http://kazaan.no-ip.com/~kazaan/item-1094206424.html *)
37    let dec2bin num len =
38      let rec d2b v fig =
39        if fig < 0 then ""
40        else
41          match (v asr fig) land 1 with
42              0 -> "0" ^ (d2b v (fig - 1))
43            | x -> "1" ^ (d2b v (fig - 1))
44      in
45        d2b num (len-1)
46    
47    (* taken from http://www.hh.iij4u.or.jp/~kazaan/old/ObjectiveCaml.html *)
48    let bin2dec num =
49      let s = string_of_int num in
50        int_of_string ("0b" ^ s)

Legend:
Removed from v.1.2  
changed lines
  Added in v.1.3

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26