?
Solved

How do I round to the nearest 0.5

Posted on 2004-11-10
4
Medium Priority
?
849 Views
Last Modified: 2010-05-18
I need to round this formula up to the nearest 0.5

{pcrsadd.lec_mins} / 60 / 18

The answer comes out at 0.412, I can round it to 0.4 but it needs to be 0.5

Thank you for your help
0
Comment
Question by:Matt_Johnston35
  • 2
  • 2
4 Comments
 
LVL 13

Expert Comment

by:EwaldL
ID: 12550432
that's the best i can come up wtih. i have only tested it with a few values (ie no negatives), so be careful ;-)

numbervar mynumber := 8.9;
numbervar myremainder := Remainder(mynumber, 0.5);
if ( myremainder < .25) then
  mynumber := mynumber - myremainder
else
  mynumber := mynumber + 0.5 - myremainder
  ;
mynumber

just pass whaterver value or database field you need into the mynumber variable.
0
 
LVL 101

Accepted Solution

by:
mlmcc earned 1000 total points
ID: 12551170
Here is a link to another formula

http://www.kenhamady.com/form22.html

Formula when changed to round to the .5 is
Round ( {database.field} / .5 , 0 ) * .5

mlmcc
0
 
LVL 13

Expert Comment

by:EwaldL
ID: 12557992
mlmcc's approach seems far better!
0
 
LVL 101

Expert Comment

by:mlmcc
ID: 12589799
Glad i could help

mlmcc
0

Featured Post

[Webinar] Cloud and Mobile-First Strategy

Maybe you’ve fully adopted the cloud since the beginning. Or maybe you started with on-prem resources but are pursuing a “cloud and mobile first” strategy. Getting to that end state has its challenges. Discover how to build out a 100% cloud and mobile IT strategy in this webinar.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I hate sub reports and always consider them the last resort in any reporting solution.  The negative effect on performance and maintainability is just not worth the easy ride they give the report writer.  Nine times out of ten reporting requirements…
There have always been a lot of questions related to when Crystal Reports evaluates report components (such as formulas, summaries, cross-tabs, charts, to name a few examples). Crystal Reports uses a two-pass reporting process to provide greater …
Exchange organizations may use the Journaling Agent of the Transport Service to archive messages going through Exchange. However, if the Transport Service is integrated with some email content management application (such as an anti-spam), the admin…
Is your OST file inaccessible, Need to transfer OST file from one computer to another? Want to convert OST file to PST? If the answer to any of the above question is yes, then look no further. With the help of Stellar OST to PST Converter, you can e…
Suggested Courses
Course of the Month16 days, 10 hours left to enroll

864 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question