This will limit it to 2 decimal places:
Code: Select all
string=R.value.toFixed(2) + ", " + G.value.toFixed(2) + ", " +B.value.toFixed(2);
You won't be able to set individual text colors if you do this on a single text layer. When an expression is applied it appears to take the style from the first character of the layer's pre-expression state.
You could either:
a. If the text is against a transparent background (e.g. created in a precomp before composited) you could create some red, green and blue solid layers, set their Blending Mode's to Color, turn on Preserve Transparency and place them over the specific bits of text.
b. Set the initial color to red through the character panel, then add a text animator ("Animate" menu just above source text property) for Fill Color > RGB, set it to Green and change the start and end of the range selector to fit the specific characters. Duplicate that animator (Animator 1) and change it to do the same for blue.