Results 1 to 5 of 5

Thread: Simulate Excel's Ceiling function in Delphi?

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Quote Originally Posted by paul_nicholls View Post
    The bit that is throwing me off is this
    Code:
    Int(X / Factor) > 0
    I suppose it is either 1 or 0 depending on the outcome. Direct conversion would probably be this:
    Code:
    Result:= (Trunc(X / Factor) - (X / Factor - Ord(Trunc(X / Factor) > 0))) * Factor;

  2. #2
    Thanks Lifepower

    Unfortunately I have since discovered that that whole routine I was converting seems to give incorrect values anyway!

    I have found that this:

    Code:
    Result := Round(n / s + 0.4) * s
    Seems to give me accurate results

    cheers,
    Paul

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •