by ULLI (93 Submissions)
Category: Math/Dates
Difficulty: Beginner
Date Added: Wed 3rd February 2021
Rating: (3 Votes)
How to convert two 32-bit dWords to a 64-bit qWord.
API Declarationsnone, pure basic
Option Explicit
Private Type tLoHi 'remember - we are little endian
Lo As Long
Hi As Long
End Type
Private Type tCurr
LoHi As Currency
End Type
Private Function Convert(ByVal HiWord As Long, ByVal LoWord As Long) As Variant
'convert two 32bit dWords to a 64bit qWord
Dim LoHi As tLoHi
Dim Curr As tCurr
LoHi.Hi = HiWord
LoHi.Lo = LoWord
LSet Curr = LoHi
Convert = CDec(Curr.LoHi) * 10000 'remove decimal point from currency
End Function
Private Sub Command1_Click()
Cls
Print "MaxPos ", Convert(&H7FFFFFFF, &HFFFFFFFF)
Print "MaxNeg ", Convert(&H80000000, 0)
Print "Plus 1 ", Convert(0, 1)
Print "Minus 1", Convert(&HFFFFFFFF, &HFFFFFFFF)
End Sub