q/kdb+, 55 bytes
Solution:
"#",raze{(last($)0x0 vs)each"h"$.0255*x[3]*x 0 1 2}100-
Examples:
q)"#",raze{(last($)0x0 vs)each"h"$.0255*x[3]*x 0 1 2}100-86 86 0 43
"#141491"
q)"#",raze{(last($)0x0 vs)each"h"$.0255*x[3]*x 0 1 2}100-28 14 0 6
"#adcef0"
q)"#",raze{(last($)0x0 vs)each"h"$.0255*x[3]*x 0 1 2}100-0 41 73 4
"#f59042"
Explanation:
Fairly straightforward, stole the 0.0255
trick from other solutions (thanks!). Evaluation is performed right to left.
"#",raze {(last string 0x0 vs) each "h"$ .0255 * a[3] * a 0 1 2}100- / ungolfed
{ } / lambda function
100- / subtract from 100 (vector)
a 0 1 2 / index into a at 0, 1 and 2 (CMY)
a[3] / index into at at 3 (K)
* / multiply together
.0255 * / multiply by 0.255
"h"$ / cast to shorts
( ) each / perform stuff in brackets on each list item
0x0 vs / converts to hex, 1 -> 0x0001
string / cast to string, 0x0001 -> ["00", "01"]
last / take the last one, "01"
raze / join strings together
"#", / prepend the hash
Notes:
Rounds numbers by default, would cost 3 bytes (_)
to floor instead before casting to short.
CMYK
values as decimals from0
to1
or is it required to do0
to100
? \$\endgroup\$