## Getting values to display number up to two decimal points

##### Getting values to display number up to two decimal points
 Author Message aghartley          Group: Awaiting Activation Posts: 16, Visits: 127 Hello,I am programming a task in which participants can earn money by guessing correctly. The cumulative money they have won is displayed in the corner of the screen so they can keep track of how much money they've made. I'd like the text to display they money they've made, with two zeros after the decimal point so it looks like a monetary value (e.g., \$3.50), rather than what it shows now, which is just one place after the decimal (\$3.5). How would I do this? Here's are some sample pieces of code that are relevant. Thanks in advance for your help!**where I define value parameters:/ balance_total = 2.00/ prevtotal = 0/ currency = "\$"/ gainincentive = .50/ loseincentive = .50/ correctguess = 0/ correctguessIn = 0**where I define the text that displays the participant's balance./ items = ("<%values.currency%> <%values.balance_total%> ")/ fontstyle = ("Verdana", 4.0%, true, false, false, false, 5, 0)/ halign = left/ hjustify = center/ vjustify = center/ size = (25%, 10%)/ position = (80%, 16%)/ txcolor = (green)/ txbgcolor = (black)/ erase = false Dave posted 8 Years Ago ANSWER         Group: Administrators Posts: 12K, Visits: 95K You can use the the format() function to do that:/ balance_total = 2.00/ prevtotal = 0/ currency = "\$"/ gainincentive = .50/ loseincentive = .50/ correctguess = 0/ correctguessIn = 0**where I define the text that displays the participant's balance./ items = ("<%values.currency%> <%format(~"%.2f~", values.balance_total)%> ")/ fontstyle = ("Verdana", 4.0%, true, false, false, false, 5, 0)/ halign = left/ hjustify = center/ vjustify = center/ size = (25%, 10%)/ position = (80%, 16%)/ txcolor = (green)/ txbgcolor = (black)/ erase = false/ ontrialbegin = [values.prevtotal=values.balance_total]/ ontrialend = [values.balance_total=values.prevtotal+values.gainincentive]/ stimulusframes = [1=balance_total]/ validresponse = (57)/ trials = [1-5=mytrial]

#### Merge Selected

Merge into selected topic...

Merge into merge target...

Merge into a specific topic ID...