• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1853
  • Last Modified:

Round up to nearest .50 or dollar

Hi experts,

I'm trying to figure out how to calculate the rate increases in my company but we have a special specs.
What I need is to increase rates by 6% but I need to round UP to the nearest 50 cents or to the dollar, whichever is closer.
EX:
my rate is 106
6% increase would be 106 + 6.36 = 112.36
This should round up to 112.5

Any questions let me know.

Thanks
cm
0
carlosmonte
Asked:
carlosmonte
  • 3
  • 2
1 Solution
 
bdreed35Commented:
Here is some logic that you can use to round to the nearest 50 cents:

Round ( ({table.rate}*1.06) / .5 , 0 ) * .5

You can replace {table.rate}*1.06 with another formula if you are already doing this calculation
0
 
carlosmonteAuthor Commented:
This rounds down to. I only need it to round UP.
0
 
bdreed35Commented:
This will always round up, except when the value is evenly divisible by .5:

local numbervar input := {table.rate}*1.06;

if remainder(input, 0.5) > 0
then (int(input/ 0.5) *.5) + .5
else input
0
 
carlosmonteAuthor Commented:
This is almost working. Thanks
how can I know when its divisible by 0.5?
I want to insert another if statement to keep the number when its ends with .5
At the moment if the input is for example 111.5 it rounds UP to 112. I want it to stay as 111.5
0
 
carlosmonteAuthor Commented:
forget last comment. Sorry my mistake, was using different formula
0

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

  • 3
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now