home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Power-Programmierung
/
CD1.mdf
/
magazine
/
nan_news
/
vol3
/
no4
/
trunc.prg
< prev
Wrap
Text File
|
1989-01-01
|
613b
|
20 lines
* Function: Truncate()
* Author: A. Timothy Wong
* Version: Clipper Summer '87
* Note(s): Truncates a number at a certain decimal place.
*
* Copyright (C) 1988 Nantucket Corp.
FUNCTION Truncate
PARAMETERS Number, DecPlaces
PRIVATE RetVal, NStr, Temp1, Temp2
NStr = STR(Number)
Temp1 = AT(".",NStr) && Position of decimal point.
Temp2 = LEN(NStr) - Temp1 && Find total decimal places.
DecPlaces = MIN(Temp2,DecPlaces) && if Total decimal places is
** less than needed.
RetVal = VAL(SUBSTR(NStr,1,Temp1 + DecPlaces))
RETURN(RetVal)