From: Jun Furuse <furuse@madiran.inria.fr>
To: stalkern2@tin.it
Cc: caml-list@inria.fr
Subject: Re: [Caml-list] How do I convert 0x hexadecimal integers to decimal integers ?
Date: Thu, 27 Mar 2003 18:58:18 +0100 [thread overview]
Message-ID: <rr8he9o1ykl.wl@madiran.inria.fr> (raw)
In-Reply-To: <200303271854.55964.stalkern2@tin.it>
> > 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
next prev parent reply other threads:[~2003-03-28 13:46 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2003-03-27 17:20 Stalkern 2
2003-03-27 17:54 ` Stalkern 2
2003-03-27 17:58 ` Jun Furuse [this message]
2003-03-27 18:24 ` Brian Hurt
[not found] ` <002701c2f48a$555fa170$0201a8c0@mordor>
2003-03-27 18:42 ` Stalkern 2
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=rr8he9o1ykl.wl@madiran.inria.fr \
--to=furuse@madiran.inria.fr \
--cc=caml-list@inria.fr \
--cc=stalkern2@tin.it \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox