Skip to main content
Question

Decimal equivalant to INT

  • December 20, 2013
  • 6 replies
  • 47 views

Forum|alt.badge.img

Hi,

within a workbench I need to split a decimal value into its whole and decimal elements using the arithmetic editor,

Extracting the whole number is easy using INT(value), however is there a formula available which will complete the same procedure with eh decimal?

I have used a workaround in the form of (value)-INT(value) which works fine, but I am interested to know if there is an out of the box formula which will do this?

Regards,

Rob

6 replies

ebygomm
Influencer
Forum|alt.badge.img+31
  • Influencer
  • December 20, 2013
You can use fmod to get the decimal part

 

 

 

In an expression evaluator

 

 

@fmod(@Value(attribute), 1.)

 

 

will give you the decimal elements

 


Forum|alt.badge.img
  • Author
  • December 20, 2013
Many thanks, that worked a treat.

 

 

Best wishes,

 

 

Rob 

takashi
Contributor
Forum|alt.badge.img+19
  • Contributor
  • December 21, 2013
Hi Rob,

 

 

Just be aware the expression returns a negative value if the original value is negative. @fmod(-1.234,1)  -->  -0.234   and also, it could bring a slight computational error in certain conditions. @fmod(1.001, 1) --> 0.00099999999999989   Alternatively, the StringSearcher could be used to split a numeric representation into integer part and decimal part at once.

 

  Takashi

Forum|alt.badge.img+5
  • December 24, 2013
If you have the INT() function to get the integer part, why not subtract the integer part from the original to get the decimal? So: dec(x) = x - int(x).

Forum|alt.badge.img+5
  • December 24, 2013
Woops, only just noticed you have my answer in your question. I don't think there is an out of the box formula, especially with only a small custom formula required.

Forum|alt.badge.img
  • Author
  • January 8, 2014
Hi,

 

 

Many thanks to everyone for the answers and suggestions, plus the overview of the potential calc issue of using fmod.

 

 

Regards,

 

 

Robb

 

 

 

 

 

 


Cookie policy

We use cookies to enhance and personalize your experience. If you accept you agree to our full cookie policy. Learn more about our cookies.

 
Cookie settings