As the HTML value is just the hexadecimal representation of the decimal value, I was going to suggest $base($rgb(0,0,127),10,16), but it reverses the RGB values, so a little more trickery is required. (Anybody know how to force an Endian?)

Basically, the HTML value is just the RGB values in hex, so you just $base() the 3 values, and string them together. So going from the hex string to $rgb() values is simple with a small loop and $base()'n each one.

If you've got the 3 separated values that you plug into $rgb(), then it's easy to go the other way as well (hell, you can swap your R and B values, and $base() the entire thing to 16!). But if you've only got the full decimal number (8323072 in your example), then you've only really got the choice of chopping up a converted value, or breaking out into it's componant values.