How do I round to the nearest 0.5

Posted on 2004-11-10
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
Question by:Matt_Johnston35
    LVL 13

    Expert Comment

    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
      mynumber := mynumber + 0.5 - myremainder

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

    Accepted Solution

    Here is a link to another formula

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

    LVL 13

    Expert Comment

    mlmcc's approach seems far better!
    LVL 100

    Expert Comment

    Glad i could help


    Featured Post

    Do You Know the 4 Main Threat Actor Types?

    Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

    Join & Write a Comment

    Crystal Reports: 5 Tests for Top Performance It is complete, your masterpiece report.  Not only does it meet your customer’s expectations, it blows them out the water, all they want is beautifully summarised and displayed in a myriad of ways. …
    Hello everyone, Hope you find this as helpful as we did. We have on the company I work for an application built in Delphi V with Crystal Reports 8. We all know that Crystal & Delphi can be temperamental sometimes and the worst thing is, nearly…
    In this sixth video of the Xpdf series, we discuss and demonstrate the PDFtoPNG utility, which converts a multi-page PDF file to separate color, grayscale, or monochrome PNG files, creating one PNG file for each page in the PDF. It does this via a c…
    Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

    755 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

    Need Help in Real-Time?

    Connect with top rated Experts

    21 Experts available now in Live!

    Get 1:1 Help Now