Decimals NOT being truncated/rounded

2351
15
Jump to solution
10-25-2017 11:51 AM
deleted-user-LNABNwA5CZcD
New Contributor III

For points, I added some geometry fields (POINT_X and POINT_Y as automatically generated), which were created as Double type.

I want them to display as my label (e.g., "35.596821, -81.235600"). I went to the numeric formatting and changed to 6 as that's the number of decimal places I want.

For some (not all; most are fine), there is infinite repeat (e.g., "-81.39291999999999"). Here is my label code: Round($feature.POINT_Y, 6) + ", " + Round($feature.POINT_X, 6)

I've played around with the field calculator, even trying to create new fields and convert to different types, but that's not working.

HELP!!!

15 Replies
StayMappy
New Contributor III

These are floats. 

0 Kudos
DanPatterson_Retired
MVP Emeritus

if you want labels, then I always use a text field to ensure that I get what I want in terms of formatting.

The inputs can be numbers (float double etc) but python formatting handles the conversions clearly and concisely without messing around with the actual numbers.

In your case if floates are the inputs, the first number is the width of the resultant string and the second number is the number of required decimals

0 Kudos
StayMappy
New Contributor III

So I will probably have to make a new field that converts the float to string and then format? I need it initially in float because that field has to be calculating the acres of a polygon. 

0 Kudos
DanPatterson_Retired
MVP Emeritus
"{:10.6f}".format(!YourNumberFieldNameHere!)  # python, parser, calculate into a text field

try it... add the text field, set the parser, vary the numbers to suit

StayMappy
New Contributor III

This works. Thanks for all the help!

0 Kudos
DanPatterson_Retired
MVP Emeritus

glad it worked Jessica

0 Kudos