Skip to main content

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

You can use fmod to get the decimal part

 

 

 

In an expression evaluator

 

 

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

 

 

will give you the decimal elements

 


Many thanks, that worked a treat.

 

 

Best wishes,

 

 

Rob 
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
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).
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.
Hi,

 

 

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

 

 

Regards,

 

 

Robb

 

 

 

 

 

 


Reply