PC SOFT

FORUMS PROFESSIONNELS
WINDEVWEBDEV et WINDEV Mobile

Accueil → WINDEV 2024 → Shift for bits
Shift for bits
Débuté par Marco Rego, 27 aoû. 2008 19:24 - 2 réponses
Posté le 27 août 2008 - 19:24
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.
Posté le 27 août 2008 - 19:50
Marco Rego schrieb:
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 << and shiftright >> , 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. a DLL then ...
(D is in fact C++ on steroids, without bee'ing too complicated)

http://www.digitalmars.com/d/

HTH Bjoern
Posté le 28 août 2008 - 01:54
Bjoern, thanx a bunch for your answer and cool code.
Yes, I konow about D, even installed DMD, Tango and Decent in my Ubuntu machine, but later decided that for now WinDev must be my priority. Will go back to it later, want to learn DWT (just wish WinDev have a GUI like GTK in Linux).
Thanks again.

Marco