PC SOFT

FORUMS PROFESSIONNELS
WINDEVWEBDEV et WINDEV Mobile

Accueil → WINDEV 2024 → Shift for bits
Shift for bits
Débuté par Marco Rego.pcs.crosspost, 28 aoû. 2008 01:56 - 1 réponse
Posté le 28 août 2008 - 01:56
Are there any shift left and right related functions for dealing with bits ?
Just found BinaryAND/OR/XOR and it is not exactly what I am looking for.
Message forwarded from pcsoft.us.windev
Posté le 28 août 2008 - 01:56
Marco Rego :
Are there any shift left and right related functions for dealing with bits ?
Just found BinaryAND/OR/XOR and it is not exactly what I am looking for.

Hi Marco,
NO, it's a shame but WD has no (or pretty less) support for bit-wise operations.
However code for shiftleft > , enjoy.
Procedure ShiftLeft(nInt, nBitsToShift)
nResult is int

WHEN EXCEPTION
ExceptionEnable()
RESULT -1
END

nResult = nInt * Power(2, nBitsToShift)

RESULT nResult
FUNCTION ShiftRight(nInt, nBitsToShift)
nRetval is int
WHEN EXCEPTION
// Capacity Error
ExceptionEnable()
RESULT -1
END
nRetval = nInt / Power(2, nBitsToShift)
RESULT nRetval

PS ..the lack of bit operations in WD is quit annoying. So I wrote all "low level" code in the D programming language. [means create a DLL]
Beside ... can't resist :
(D is in fact C++ on steroids, without being too complicated, at least ...compared to C++ ;) )
http://www.digitalmars.com/d/
HTH Bjoern