FloatField to save just 1 decimal

86 views
Skip to first unread message

Irtaza Ali Ajmal

unread,
Apr 21, 2021, 11:38:06 AM4/21/21
to oTree help & discussion
Hello, I've a question.

How can I set a variable floatfield that should give me the value with just 1 decimal.

For example
In the payment it records the value in data like this. 5.3435
I just want it to record with one decimal. Like this 5.3 or 5.4

Kind Regards
Irtaza

Chris @ oTree

unread,
Apr 21, 2021, 11:40:59 AM4/21/21
to oTree help & discussion
  In before_next_page, you can do:

player.my_field = round(player.my_field, 1)

Irtaza Ali Ajmal

unread,
Apr 21, 2021, 11:48:40 AM4/21/21
to ot...@googlegroups.com

Hello Chris,

So the variable is to get the final payment.

I've declared it like this, as you can see in the screenshot 1.

And In the screenshot 2, in the templates, it does show with just 1 decimal.

But as you can see in the screenshot 3, in the recorded data it shows with more than 1 decimal. I want it to record with just 1 decimal as in the screenshot 2.

Kind Regards

Irtaza

--
You received this message because you are subscribed to a topic in the Google Groups "oTree help & discussion" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/otree/mlhlZZ20svY/unsubscribe.
To unsubscribe from this group and all its topics, send an email to otree+un...@googlegroups.com.
To view this discussion on the web, visit https://groups.google.com/d/msgid/otree/872f463c-9637-4317-ae5d-6210ea94aebdn%40googlegroups.com.
1.PNG
2.PNG
3.PNG
Reply all
Reply to author
Forward
0 new messages