8 Replies Latest reply on May 19, 2011 10:47 AM by gkaiseril

    Decimal places

    govtech77

      Hi, I need a calculation to stop or round to 2 decimal places.

      Here is my script

      event.value = ( this.getField("dry weight 1Row1").value) /
         ( this.getField("current growth ungrazed 1Row1").value  *
          this.getField("growth curve comple ted 1Row1").value * this.getField("of normal produc tion 1Row1").value);

      I just need to know what to put to get it to only go to two decimal places.

       

      Thank you

        • 1. Re: Decimal places
          try67 MVP & Adobe Community Professional

          Why not set the field's format to Number with 2 decimals?

          • 2. Re: Decimal places
            govtech77 Level 1

            I have tried that but when I go into reader mode and try it out and enter information into the fields being used for the calculations I get an error message stating that the value entered does not match the format of the field being calculated.

            • 3. Re: Decimal places
              gkaiseril MVP & Adobe Community Professional

              Is the field's value being completed by a calculation?

               

              If so, does that calculation involve division?

               

              Try setting the field's format to "None" and see what displays.

              • 4. Re: Decimal places
                govtech77 Level 1

                Thank you. I had just done that. When I set the other four fields

                format to none and changed the calculated field to number with

                two decimal places it works.

                • 5. Re: Decimal places
                  govtech77 Level 1

                  Sorry. When I cleared the form and tried again, I recieved the same message "The value entered does not match the format of the field [ Recon struction factor C DEFRow1]

                  • 6. Re: Decimal places
                    gkaiseril MVP & Adobe Community Professional

                    Set the format of the "Recon struction factor C DEFRow1" to "None" and see what happens.

                     

                    You could also use the following script for testing:

                     

                    var nDW = this.getField("dry weight 1Row1").value;
                    var nGU = this.getField("current growth ungrazed 1Row1").value;
                    var nGC = this.getField("growth curve comple ted 1Row1").value;
                    var nNP = this.getField("of normal produc tion 1Row1").value;

                    console.show();
                    console.clear();
                    console.println("Some debugging data:");
                    console.println("dry weight: " + nDW);
                    console.println("current growt ungrazed: " + nGU);
                    console.println("growth curve couple ed: " + nGC);
                    console.println("of normal procc tion: " + nNP);
                    console.println("divisor: " + (nGU * nGC * nNP));
                    console.println("result: " + ( nDW / (nGU  * nGC * nNP) ) );

                    event.value = "";
                    if((nGU * nGC * nNP) != 0) {
                    event.value = nDW / (nGU  * nGC * nNP);
                    }

                     

                    Note what is dispalye as you enter each value.

                    1 person found this helpful
                    • 7. Re: Decimal places
                      govtech77 Level 1

                      That script works correctly and the total is infinity until all numbers are put in. It seems to work perfectly until I try to go to my next row that requires that number to do the next calculation.

                       

                      I have rows A, B, C, D, E, F, G, H

                      row G= C/(D*E*F)

                      row H= B*G

                      • 8. Re: Decimal places
                        gkaiseril MVP & Adobe Community Professional

                        You need to make sure you are not dividing by zero and you have the correct field calculation order