Follow along with the video below to see how to install our site as a web app on your home screen.
Note: This feature may not be available in some browsers.
MAP
RoundToNearest (REAL xVal, REAL xRoundTo),REAL
END
RoundToNearest PROCEDURE(REAL xVal, REAL xRoundTo)
!Assumes that xRoundTo is >= 0
!When xRoundTo is = 0, then xVal should be returned
_mod REAL
RetVal REAL
CODE
_mod = xVal % xRoundTo ! % is the MODULUS operator
!LRM: (A % B gives the remainder of A divided by B)
IF _mod >= xRoundTo / 2
RetVal = xVal + (xRoundTo - _mod) !Round UP
ELSE
RetVal = xVal - _mod !Round Down
END
RETURN Retval
!contents of MyProcs.inc
RoundToNearest (REAL xVal, REAL xRoundTo),REAL
!contents of MyProcs.clw
MEMBER
MAP
END
RoundToNearest PROCEDURE(REAL xVal, REAL xRoundTo) !,REAL
!Assumes that xRoundTo is >= 0
!When xRoundTo is = 0, then xVal should be returned
_mod REAL
RetVal REAL
CODE
_mod = xVal % xRoundTo ! % is the MODULUS operator
!LRM: (A % B gives the remainder of A divided by B)
IF _mod >= xRoundTo / 2
RetVal = xVal + (xRoundTo - _mod) !Round UP
ELSE
RetVal = xVal - _mod !Round Down
END
RETURN Retval
MAP
END
MAP
INCLUDE('builtins.clw')
END
RoundToTheNearest PROCEDURE (REAL xVal, REAL xRoundTo) !,REAL ! Declare Procedure
! Start of "Data Section"
! [Priority 4000]
_mod REAL
RetVal REAL
! End of "Data Section"
CODE
! Start of "Add additional DebugHook statements"
! [Priority 5000]
! End of "Add additional DebugHook statements"
! Start of "Processed Code"
! [Priority 4000]
_mod = xVal % xRoundTo ! % is the MODULUS operator
!LRM: (A % B gives the remainder of A divided by B)
IF _mod >= xRoundTo / 2
RetVal = xVal + (xRoundTo - _mod) !Round UP
ELSE
RetVal = xVal - _mod !Round Down
END
RETURN Retval
! End of "Processed Code"
! Start of "Procedure Routines"
! [Priority 3500]
! End of "Procedure Routines"
! Start of "Local Procedures"
! [Priority 5000]
! End of "Local Procedures"