Skip to main content
Solved

Remove decimal and decimal values without rounding.

  • March 3, 2017
  • 6 replies
  • 200 views

katericondo
Contributor
Forum|alt.badge.img+8

Say I have 105.6546 and 5646.546356, how can I drop only the decimal and values to the right of the decimal? So my final values will be 105 and 5646.

Best answer by jdh

Using the arithmetic editor in any of the transformers that create attributes, you can use @int() or @floor().

 

@int will truncate the value, @floor will return the next lowest integer, these are identical for positive values, but will differ by 1 for negative values.

 

@int(10.1) =>10

 

@floor(10.1) =>10

 

@int(-10.1) => -10

 

@floor(-10.1) => -11
This post is closed to further activity.
It may be an old question, an answered question, an implemented idea, or a notification-only post.
Please check post dates before relying on any information in a question or answer.
For follow-up or related questions, please post a new question or idea.
If there is a genuine update to be made, please contact us and request that the post is reopened.

6 replies

erik_jan
Contributor
Forum|alt.badge.img+23
  • Contributor
  • March 3, 2017

The ExpressionEvaluator transformer can be used, using the floor function. It will be in the Math section.


katericondo
Contributor
Forum|alt.badge.img+8
  • Author
  • Contributor
  • March 3, 2017

The ExpressionEvaluator transformer can be used, using the floor function. It will be in the Math section.

Hi Erik_jan, it created a new field but all values were null.

 

 


jdh
Contributor
Forum|alt.badge.img+40
  • Contributor
  • Best Answer
  • March 3, 2017

Using the arithmetic editor in any of the transformers that create attributes, you can use @int() or @floor().

 

@int will truncate the value, @floor will return the next lowest integer, these are identical for positive values, but will differ by 1 for negative values.

 

@int(10.1) =>10

 

@floor(10.1) =>10

 

@int(-10.1) => -10

 

@floor(-10.1) => -11

erik_jan
Contributor
Forum|alt.badge.img+23
  • Contributor
  • March 3, 2017

The ExpressionEvaluator transformer can be used, using the floor function. It will be in the Math section.

You have to set the ExpressionEvaluator to overwrite existing attribue:

 

To get this result:

 

 


itay
Supporter
Forum|alt.badge.img+18
  • Supporter
  • March 3, 2017

I would use the AttributeSplitter and use the first element of the lists.


takashi
Celebrity
  • April 15, 2017

For what it's worth, if the @floor function satisfies your requirement, the AttributeRounder (Decimal Places: 0, Round-off Direction: Down) can also be used. Instead of the @int function, the StringReplacer with this setting works for you.

  • Mode: Regular Expression Replace
  • Text to Replace: (.+)\\..*
  • Replacement Text: \\1