home *** CD-ROM | disk | FTP | other *** search
/ SPACE 2 / SPACE - Library 2 - Volume 1.iso / program / 138 / pascal / fixreal.pas < prev    next >
Encoding:
Pascal/Delphi Source File  |  1987-05-13  |  1.0 KB  |  32 lines

  1. procedure FIXREAL(Var RealTotal : Real; DecPlaces : Byte);
  2. {******************************************************************************
  3. **
  4. **                       Procedure REALTOTAL
  5. **
  6. **        Purpose : To correct Real Number Errors by rounding them off to a
  7. **                  specified accuracy/decimal point.
  8. **
  9. **        Passed  : RealTotal - VAR Real number passed to routine to adjust
  10. **                  DecPlaces - Integer degree to "FIX" the passed number
  11. **
  12. **                  Written by : Stewart J Dimon, c1986
  13. ******************************************************************************}
  14.  
  15. Var
  16.  
  17.     I        : Integer;
  18.     Decimals : Real;
  19.  
  20. begin { FIXREAL }
  21.    If (DecPlaces > 0) Then
  22.       begin
  23.       Decimals := 1.0;
  24.       For I := 1 to DecPlaces Do
  25.          Decimals := 10.0 * Decimals;
  26.       RealTotal := RealTotal * Decimals;
  27.       RealTotal := Round(RealTotal);
  28.       RealTotal := Trunc(RealTotal);
  29.       RealTotal := RealTotal/Decimals;
  30.       end {If DecPlaces > 0}
  31. end; {Procedure FIXREAL}
  32.