Display text: Percentages?
Hello
I get stumped by the silliest of things. I have a value (real) which is the division of two real variables. Can I format the Display Text to have the value displayed as a percentage, such as "12.34%"? Or do I have to multiply by 100 and concatenate a "%" in there? LOL.
Thanks, regards.
Comments
you could do display test like so game.value.."%"
YEs, @BBEnk, that would be the concatenate option. But how can I format a real variable to two decimal places? Thanks!
Using the Precision Function:
prec(your.number,2)
You're welcome!
Thanks, @pHghost ! So close, yet still a bit to go. I was trying out padInt and padReal when I saw your response.
Thanks to both, regards.
I'm pretty sure the precision function is (like the modulus '%' function) no longer recommended by GameSalad, I guess its days are numbered and will eventually get dropped as the code base is evolved . . . . the recommendation to ensure future compatibility is to use 'round' and 'roundTo' instead . . . so basically roundTo(your.number,2).
Also I've heard it said that the precision function needs to convert the numbers to text before doing its magic and then convert the results back to a number, which is meant to be a slower less efficient method than staying in the world of numbers (which 'round' does).
@Socks -- good to know! Had no idea these functions might get dropped by GS soon.