Hi,
If you're running on a 18F series then you could enable support for LONGS in the compiler and simply be done with it. It will increase the code size quite a bit though so I understand if you're trying to avoid it.
Have you looked at the DIV32 operator? I'm not 100% sure it'll work with a variable but I think it will, try it out:
Code:
Dummy VAR WORD
Result VAR WORD
Divider VAR WORD
' Be aware that Divider must be at least 8 or Result will
' overflow and show the wrong result.
Divider = 145
Dummy = 500*1000 ' Produce intermediate result of 500000
Result = DIV32 Divider ' Divide the intermediate result
/Henrik.
Bookmarks