Expand my Community achievements bar.

Round Up on Thousandths decimal using FormCalc

Avatar

Former Community Member

Currently I have a numeric object called perHour and one called, payPeriod.  I am using a FormCalc formula to round up to the 2nd decimal point (hundreth) based on the value in the 3rd decimal spot (thousandth).  Using this formula:  $ = Round(perHour, 2)  *  (what ever I want).  I have been asked to create a value that rounds the 2nd decimal spot (hundreths) up to the next digit value if the 3rd decimal spot (thousandths) is 1 or higher.

Example:  2.342345    using current code -----> 2.34 * (what ever I want)

               2.342345    New code (unknown) -----> 2.35 * (what ever I want)

Can anyone provide an answer???? Does this code involve the ceiling / floor concept. ----Allen

3 Replies

Avatar

Level 4

Javascript is so much cuter and I am not good with formcalc

Try this one. It will round till 999 (f.ex 333 -> 300) normally and after 1000 upwards to the next thousand (1001 -> 2000)

You can also add Text like in the lower case if you take a Textfield.


var a = NumerischesFeld1.rawValue;
var b = a;

if (a < 1000)

{

a = Math.round(a/100);

a = a*100;

this.rawValue = a;
}

if (a >= 1000)

{
b = Math.floor(b/1000);
b = b * 1000;
}

if (b < a)
{

b = b + 1000;
this.rawValue = b + " what ever you want";

}

Hope I got you right.

Lisa

Avatar

Former Community Member

I know you like JavaScript, it is much easier if you ask me.  I assume your answer is written in Javascript, right?  For the Event field should I select Caclulate?  Also, there were no decimal points in your numbers.  Should I put a decimal point infront of your whole numbers? example: a < (1000)  should be a < (.1000)  just for clarification and many thanks in advance for your help.  One last question, do you get paid for assisting us and is based on the solution (may of helped or answered corrrect).-----Allen

Avatar

Former Community Member

I solved it myself......I only needed to add .004 to the main value----yes