Set Value not pushing value after decimal

I am having field float type field named value and another field as answer. What I am doing is on inserting a float value let say, 14.00 , I am using set value to push that value to field answer. Right now what is happening is if I am inserting 14.00, only 14 is inserted (but I want 14.00 to be inserted). Similarly, if I insert 9.80 , I want 9.80 to be pushed but its 9.8 which is pushed. Any help how to achieve that because I want 2-decimal place value whether it has to be zero.

Also, I dont want to make my field as Data as there is validation that only float values can be inserted.

In the field change its Precision
to 2

Thats not pushing the real float value but pushing 14.00 as 14

what type of the data in “answer” field ?

Small Text

when assigning value
a = 10.0
p = 2
s = ‘%.{0}f’.format(p) % a
print s

or

try Decimal module

from decimal import Decimal
num1 = Decimal(‘10.000’)
str(num1)
‘10.000’
num2 = Decimal(‘10.00’)
str(num2)
‘10.00’

My Bad :stuck_out_tongue: . Just used .toFixed(2) as:

frm.doc.value.toFixed(2);

and it worked like charm :slight_smile: