From mboxrd@z Thu Jan 1 00:00:00 1970 Received: (from majordomo@localhost) by pauillac.inria.fr (8.7.6/8.7.3) id OAA09466; Fri, 28 Mar 2003 14:46:19 +0100 (MET) X-Authentication-Warning: pauillac.inria.fr: majordomo set sender to owner-caml-list@pauillac.inria.fr using -f Received: (from xleroy@localhost) by pauillac.inria.fr (8.7.6/8.7.3) id OAA09176 for caml-list@pauillac.inria.fr; Fri, 28 Mar 2003 14:46:18 +0100 (MET) Received: from nez-perce.inria.fr (nez-perce.inria.fr [192.93.2.78]) by pauillac.inria.fr (8.7.6/8.7.3) with ESMTP id SAA16894 for ; Thu, 27 Mar 2003 18:58:24 +0100 (MET) Received: from madiran.inria.fr (madiran.inria.fr [128.93.8.77]) by nez-perce.inria.fr (8.11.1/8.11.1) with ESMTP id h2RHwOX09811 for ; Thu, 27 Mar 2003 18:58:24 +0100 (MET) Received: from madiran.inria.fr ([128.93.8.77] ident=furuse) by madiran.inria.fr with esmtp (Exim 3.35 #1 (Debian)) id 18ybdv-0007ZF-00; Thu, 27 Mar 2003 18:58:23 +0100 Date: Thu, 27 Mar 2003 18:58:18 +0100 Message-ID: From: Jun Furuse To: stalkern2@tin.it Cc: caml-list@inria.fr Subject: Re: [Caml-list] How do I convert 0x hexadecimal integers to decimal integers ? In-Reply-To: <200303271854.55964.stalkern2@tin.it> References: <200303271820.34803.stalkern2@tin.it> <200303271854.55964.stalkern2@tin.it> User-Agent: Wanderlust/2.8.1 (Something) SEMI/1.14.3 (Ushinoya) FLIM/1.14.3 (=?ISO-8859-4?Q?Unebigory=F2mae?=) APEL/10.3 MULE XEmacs/21.4 (patch 6) (Common Lisp) (i386-debian-linux) MIME-Version: 1.0 (generated by SEMI 1.14.3 - "Ushinoya") Content-Type: text/plain; charset=US-ASCII X-Spam: no; 0.00; furuse:01 caml-list:01 scanf:01 lsr:03 btw:03 let:04 functions:05 decimal:05 color:94 integers:05 hexadecimal:05 converting:05 integer:06 i'd:06 notation:06 X-Spam: no; 0.00; furuse:01 caml-list:01 scanf:01 lsr:03 btw:03 let:04 functions:05 decimal:05 color:94 integers:05 hexadecimal:05 converting:05 integer:06 i'd:06 notation:06 Sender: owner-caml-list@pauillac.inria.fr Precedence: bulk > > I'd need a function to turn hexadecimal integers like > > 0xb8f99c > > ( a Color in hexadecimal notation) to integer 3ples (e.g. `RGB > > (184*256,249*256,156*256), always a color). > > > > Shall I use Scanf functions and then some function converting hexadecimal > > numbers to decimal? what would this function be? let hex = 0xb8f99c in let b = hex land 0xff in let g = (hex lsr 8) land 0xff in let r = (hex lsr 16) land 0xff in `RGB (r lsl 8, g lsl 8, b, lsl 8) BTW, if I prefere the following to get the conversion [0..255] => [0..65535]: `RGB (r lsl 8 + r, g lsl 8 + g, b lsl 8 + b) -- jun ------------------- To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/ Beginner's list: http://groups.yahoo.com/group/ocaml_beginners