Haskell, using the word8 type to ensure the inputs are from 0-255.
import Data.Bits import Data.Word hexMap :: (Integral a) => a -> Char hexMap = ("0123456789ABCDEF"!!) . fromIntegral toHex :: Word8 -> String toHex word = let lo = word .&. 15 hi = word .&. 240 in hexMap lo : hexMap (hi `shift` (-4)) : [] rgb :: Word8 -> Word8 -> Word8 -> String rgb r g b = toHex r ++ toHex g ++ toHex b
Are you sure you want to hide this comment? It will become hidden in your post, but will still be visible via the comment's permalink.
Hide child comments as well
Confirm
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
Haskell, using the word8 type to ensure the inputs are from 0-255.