I have a field "folio" formatted as a number with decimal. I added a new string field "folio_1" and using field calculator to populate it with the value of "folio". The problem is that the new field drops the zero at the end of all the numbers. How can I conserve the integrity of the number with decimal when converting a number field to a string one?

Folio            Folio_1
32901.0640       32901.064
  • Better still, include the code as ASCII text in the question. You will need to use explicit formatting to force trailing zeros.
    – Vince
    Jun 14, 2019 at 13:23
  • I am using 10.6.1
    – Maresia
    Jun 14, 2019 at 13:23
  • Folio is datatype Double? You Always want four decimal places in Folio_1?
    – BERA
    Jun 14, 2019 at 13:27
  • Folio is double type and i want 4 decimal places in Folio_1 to match a field in another layer.
    – Maresia
    Jun 14, 2019 at 13:36

2 Answers 2


A quick solution for converting to string is to use str() but then you loose the last zeros.


for the best control on the format of your text field, I suggest that you use the "format" from Python. The basic command (just below) is just a longer way to write str()


But then you cn do a lot more. In your case, if you want always 4 decimal, then it is


f mean float, with any number before the decimal point and 4 digits after the decimal point (this will add zeros if less than 4 decimal, and remove decimals if there are more than 4. Beware that this is not a rounding but a truncation)

  • holy moly!!!!!! it solved the problem!!! thank you very much
    – Maresia
    Jun 14, 2019 at 14:13
  • 1
    As the Help page states, "Please do not add a comment on ... an answer to say "Thank you". ... If you want to say 'thank you,' vote on or accept that person's answer, or simply pay it forward by providing a great answer to someone else's question."
    – Vince
    Jun 14, 2019 at 20:43

In QGIS you can open the attribute table of the layer and then press Ctrl+I to open the field calculator. Then give it a name folio_1, set the length and precision parameters accordingly (in your case 4). And then just select folio from the list of drop-down options under the Fields and Values tab.

  • I am using arcgis10.6.1, and your suggestion will still give me a field formatted as a text?
    – Maresia
    Jun 14, 2019 at 13:37
  • If you set the Output field type as text(string), then yes. Not sure how to handle this in Arc, but it would be a very similar process.
    – Momchill
    Jun 14, 2019 at 13:45

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.