Here's how I usually handle the health gradient.

Code:

("|cff%02x%02x00"):format(math.ceil(math.max(math.min(2*(1-percent),1),0)*255),math.ceil(math.max(math.min(2*percent,1),0)*255));

Note:

*percent* is a float value clamped between 0 and 1. This scales the percent up and clamps it afterward to produce

|cffffff00 at 0.5 rather than

|cff808000.