BcdRound

Method
Rounds a BCD number.

Category
BCD

 

Syntax
Sub BcdRound(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 rounded.

 

Example

hBCD = CF1.AllocBcd

  tmpLong = -1.5

  CF1.LongToBcd tmpLong, hBCD

  CF1.BcdRound hBCD, 0

  tmpVar = CF1.BcdToLong(hBCD)

  If CLng(tmpVar) = Int(tmpLong) Then

  logWr "BcdRound OK"

  Else

  logWr "BcdRound failed"

  End If

  CF1.FreeBcd hBCD

 

Comments
BcdRound rounds the BCD number hBcd to contain Cnt digits.

Examples:

Original BCD Number:

Cnt:

Result:

123.45

1

123.5

123.45

0

123

126.45

-1

130

153.45

-2

200

123.45

-40

0

-123.45

1

-123.5



© 2009 Microsoft Corporation. All rights reserved.