We have a custom code running for creating description automatically, it works fine but lately we have seen a lot of examples where the description generated is rounded off.
The code being used is
t = ‘{0:.3g}’.format(s)
Now the problem is that when a person enters 12.99 in place of s the system is returning t as 13 instead of 12.99
I am unable to find out why is it giving me such output.
–
You received this message because you are subscribed to the Google Groups "ERPNext Developer Forum" group.
We have a custom code running for creating description automatically, it works fine but lately we have seen a lot of examples where the description generated is rounded off.
The code being used is
t = '{0:.3g}'.format(s)
Now the problem is that when a person enters 12.99 in place of s the system is returning t as 13 instead of 12.99
I am unable to find out why is it giving me such output.
–
You received this message because you are subscribed to the Google Groups “ERPNext Developer Forum” group.
We have a custom code running for creating description automatically, it works fine but lately we have seen a lot of examples where the description generated is rounded off.
The code being used is
t = '{0:.3g}'.format(s)
Now the problem is that when a person enters 12.99 in place of s the system is returning t as 13 instead of 12.99
I am unable to find out why is it giving me such output.
–
You received this message because you are subscribed to the Google Groups “ERPNext Developer Forum” group.
Using '{0:.3f}'.format(s) would definitely resolve the issue in case s= 12.99 but what if s=15 then it would give an output of 15.000
Would using '{0:.4g}' instead of .3f not result in any heart burns later. Since I am unable to foresee a problem with .4g as I don't want the trailing zeros.
We have a custom code running for creating description automatically, it works fine but lately we have seen a lot of examples where the description generated is rounded off.
The code being used is
t = '{0:.3g}'.format(s)
Now the problem is that when a person enters 12.99 in place of s the system is returning t as 13 instead of 12.99
I am unable to find out why is it giving me such output.
–
You received this message because you are subscribed to the Google Groups "ERPNext Developer Forum" group.
"%s" % (n if float(n) == int(n) else round(n, 3),)
Thanks,
Anand.
On 27-Jun-2013, at 11:40 AM, Aditya Duggal <ad...@rigpl.com> wrote:
Hi Anand,
Using '{0:.3f}'.format(s) would definitely resolve the issue in case s= 12.99 but what if s=15 then it would give an output of 15.000
Would using '{0:.4g}' instead of .3f not result in any heart burns later. Since I am unable to foresee a problem with .4g as I don't want the trailing zeros.
We have a custom code running for creating description automatically, it works fine but lately we have seen a lot of examples where the description generated is rounded off.
The code being used is
t = '{0:.3g}'.format(s)
Now the problem is that when a person enters 12.99 in place of s the system is returning t as 13 instead of 12.99
I am unable to find out why is it giving me such output.
–
You received this message because you are subscribed to the Google Groups “ERPNext Developer Forum” group.