[<<Previous Entry] [^^Up^^] [Next Entry>>] [Menu] [About The Guide]
  ROUND()           Returns unpredictable results.

  Clipper Version  1.29 dtd 04/15/91 (and Summer '87).

  Problem Statement

  The ROUND() function, like its predecessor in S'87, does not return
  the desired result, in certain cases.

  Cause
  Unknown.

  Work Around(s)

  The following function seems to do the trick:

  FUNCTION ROUNDIT(nNumber, nPlaces)
  nPlaces := IF( nPlaces == NIL, 0, nPlaces )
  RETURN IF(nNumber < 0.0, -1.0, 1.0) * ;
         INT( ABS(nNumber) * 10 ^ nPlaces + 0.50 + 10 ^ -12 ) / 10 ^ nPlaces

  Notes
  FYI, here are some particularly unique numbers which do not Round() up.
    1.265   146.795   8.245   18.435   10.165   16.685
    1.025     4.645   8.155   35.105  286.335    4.515  4.225


This page created by ng2html v1.05, the Norton guide to HTML conversion utility. Written by Dave Pearson