hex2seq() and seq2hex()
- Posted by Lewis Townsend <keroltarr at HOTMAIL.COM> Jul 15, 1999
- 493 views
Hello everyone, I'm writing a couple of routines for converting between a hex value and a sequence: eg: #RRGGBB --> {#RR,#GG,#BB} and {#RR,#GG,#BB} --> #RRGGBB If anyone has better ones or knows of better ones please post them. BTW, my second one (seq2hex()) doesn't seem to work right, I'd like to know why. Here they are: function hex2seq (atom hex) sequence seq seq = {0,0,0} seq[1] = floor (hex / #010000) seq[2] = floor (hex / #000100) -seq[1]*#100 seq[3] = floor (hex / #000001) -seq[1]*#10000 -seq[2]*#100 return seq end function function seq2hex (sequence seq) return seq[1]*#1000 + seq[2]*#100 + seq[3] end function later, Lewis Townsend _______________________________________________________________ Get Free Email and Do More On The Web. Visit http://www.msn.com