Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    New to the CF scene
    Join Date
    Jul 2013
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Adobe pdf multiplication and rounded result

    "How do I round a result of a multipliation of 2 textboxes?
    Example: if the result of Text1*Text2 = 8.16 or 8.17, the result should retrun 8.15; if the result of Text1*Text2=8.18 or 8.19, then the result should return 8.20 and so on.

  • #2
    Supreme Master coder! Philip M's Avatar
    Join Date
    Jun 2002
    Location
    London, England
    Posts
    17,731
    Thanks
    202
    Thanked 2,508 Times in 2,486 Posts
    Code:
    <script type = "text/javascript">
    var num = 8.16; // number to round to nearest 0.05
    var rf = 0.05; //   rounding factor 
    var result = (Math.round(num/rf)*rf).toFixed(2);  // result is 8.15
    alert (result);
    </script>
    Quizmaster: Which French premier signed the Treaty of Versailles?
    Contestant: Charles de Gaulle

    All the code given in this post has been tested and is intended to address the question asked.
    Unless stated otherwise it is not just a demonstration.


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •