我需要使用kernel32的SetFilePointer函数来读取磁盘的扇区,该扇区的地址包含在用于大小问题的double中。我知道ReadFile函数接受loword和hiword一样长的参数,但是我无法将我的双精度地址拆分成两个单词。
我尝试了使用Mod和Fix的几种方法,但最后我只有溢出错误。
LoWord = CLng(dNum Mod CDbl(4294967295)) 'Dont care the number I use, I always get overflow error
Run Code Online (Sandbox Code Playgroud)
要么
LoWord = CLng(FMod(dNum, 4294967295#))
HiWord = CLng(dNum - (FMod(dNum, 4294967295#))) 'tryed different number to see the behaviour, don't care
Run Code Online (Sandbox Code Playgroud)
哪里
Public Function FMod(a As Double, b As Double) As Double
FMod = a - Fix(a / b) * b
'http://en.wikipedia.org/wiki/Machine_epsilon
'Unfortunately, this function can only be accurate when `a / b` is outside [-2.22E-16,+2.22E-16]
'Without this correction, FMod(.66, .06) = 5.55111512312578E-17 …Run Code Online (Sandbox Code Playgroud) vb6 ×1