Method
Truncates a BCD number.
Category
BCD
Syntax
Sub BcdTrunc(ByVal hBcd As Long, ByVal Cnt As Long)
hBcd
The handle to the BCD number.
Cnt
The number of digits to which the BCD number will be truncated.
Example
hBCD = CF1.AllocBcd
tmpLong = -1.5
CF1.LongToBcd tmpLong, hBCD
CF1.BcdTrunc hBCD, 0
tmpVar = CF1.BcdToLong(hBCD)
If CLng(tmpVar) = Fix(tmpLong) Then
logWr "BcdTrunc OK"
Else
logWr "BcdTrunc failed"
End If
CF1.FreeBcd hBCD
Comments
BcdTrunc truncates the BCD number referenced by hBcd to contain Cnt
digits.
Examples:
Original BCD Number: |
Cnt: |
Result: |
123.45 |
1 |
123.4 |
123.45 |
0 |
123 |
123.45 |
-1 |
120 |
123.45 |
-2 |
100 |
123.45 |
-40 |
0 |
-123.45 |
1 |
-123.4 |