Jump to content

Rounding up to the nearest 5


rsheldon

Recommended Posts

I am using FusionPro 9.0.3 in Acrobat 10.1.8 on the Mac running OS 10.8.5. I am trying to use the math function to round up an entry in my database to the nearest $5 amount (i.e., $6.00 to $10.00) I need help writing a rule to do this. The second part of the equation is to take the same number (i.e., $6.00) multiply this by 1.5 and then round up to the nearest $5.00 amount (i.e., $6.00 x 1.5 = 9.00, but needs to equal $10.00)
Link to comment
Share on other sites

If I understand your question correctly, I think this might work.

 

Math.ceil rounds up, Math.floor rounds down and Math.round rounds to the nearest integer. You may need to adjust this.

 

Part 1:

I am trying to use the math function to round up an entry in my database to the nearest $5 amount (i.e., $6.00 to $10.00) I need help writing a rule to do this.

return Math.ceil(Field("Number")/5)*5;

 

Part 2:

The second part of the equation is to take the same number (i.e., $6.00) multiply this by 1.5 and then round up to the nearest $5.00 amount (i.e., $6.00 x 1.5 = 9.00, but needs to equal $10.00)

var x = (Field("Number")*1.5)

return Math.ceil(x/5)*5;

Edited by David Miller
Link to comment
Share on other sites

Good Morning David,

 

Thank you ever so much for your reply. I have created a rule based off of the function you posted and everything seems to be working great. You hit the nail right on the head. It is a wonderful thing being able to post to this forum knowing someone out there has encountered the same issues you have and their willingness to share their solutions.

 

Thank You again,

Rob Sheldon

Link to comment
Share on other sites

  • 1 year later...
I need to know if we can round up or down based on the decimal for another job now. Can someone please let me know?

 

i.e., $10.02 to $10 or $10.50 to $11.

 

var x = Field("Number")

return Math.round(x);

 

or

 

return Math.round(Field("Number"));

Edited by David Miller
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...