449,221 Members | 1,663 Online
Need help? Post your question and get tips & solutions from a community of 449,221 IT Pros & Developers. It's quick & easy.

# Round and Ceil problem

 P: n/a I have a problem that I can't seem to solve. I have checked the round, ceil and floor functions and they don't seem to do what I want. I have an entry like this That outputs \$111.29, the result of multiplying 104.50x.065 with the answer rounded to 2 decimal places, then adding in the 104.50 of the \$ad1day variable. What I want to do is multiply the \$ad2day variable by the \$tax and come up with a result that will round up any remainder past two decimal places to the next decmial place. In the example above, the (\$ad2day * \$tax) comes out to 6.7925. I want to round that up to 2 decimal places to 6.80 if there is *any* remainder past the two digits. So 6.2401 would be 6.25, 6.2499 would be 6.25, etc. Round doesn't seem to do it and ceil only works (i think anyway) rounding up to whole numbers. What do I need to do to get the result the way I want it? Thanks Jul 17 '05 #1
4 Replies

 P: n/a Jack wrote: I have checked the round, ceil and floor functions and they don't seem to do what I want. [...] So 6.2401 would be 6.25, 6.2499 would be 6.25, etc. What do I need to do to get the result the way I want it? \$x = 6.2501; \$y = ceil(\$x * 100) / 100; // 6.26 -- Mail sent to my "From:" address is publicly readable at http://www.dodgeit.com/ == ** ## !! !! ## ** == TEXT-ONLY mail to the complete "Reply-To:" address ("My Name" ) may bypass the spam filter. I will answer all pertinent mails from a valid address. Jul 17 '05 #2

 P: n/a Pedro Graca wrote: Jack wrote: [...]So 6.2401 would be 6.25, 6.2499 would be 6.25, etc.What do I need to do to get the result theway I want it? \$x = 6.2501; \$y = ceil(\$x * 100) / 100; // 6.26 Okay thanks, but that assumes that I already know the value of \$x when in fact I won't. How can I incorporate that into my original statement of \$ad2day = round((\$ad2day * \$tax)+ \$ad2day, 2); I really don't want to write a function for each of my 150 entries. Jul 17 '05 #3