Breaking down a large hex number.

new topic     » topic index » view thread      » older message » newer message

In a program I'm working on, I have a large number expressed in hexadecimal,
in the format of

blue = #1111222233333344444455677777789ABBBBBBCDEFF11
--Euphoria informs me this is about 1e+053

Where each "group" of numbers defines a trait (ie. "2222" is measurement for
foo, while "A" is a measurement of bar)

I'm trying to turn this mammoth into something more friendly to work with,
along the lines of
{#1111,#2222,#333333....}
Now, just to make things more complicated, some of the numbers are themselves
"groups" of the sort used in HTML color codes, for instance, "#333333" needs
to become {51,51,51} so that the entire sequence ends up looking like:
{#1111,#2222,{#33,#33,#33}...}

The way I see to do this is using sprintf to turn the number into a string,
break it apart based on position, then turns the strings back into correct
numerical form within the final format.  This seems like a rather round about
way of doing things, but I've done something similiar in the past so I know it
works.  Does anyone know of another way of doing this?  I know Mozilla can't
be going through this sort of nonsense every time it needs to figure out what
color a HTML document is.

--
                 Nic (RedWord)Smith
Alt.config Guide:
        http://nic.dreamhost.com/alt.config

new topic     » topic index » view thread      » older message » newer message

Search



Quick Links

User menu

Not signed in.

Misc Menu