Highlighted
Absent Member.
Absent Member.
595 views

[archive] Bit Shifts

[Migrated content. Thread originally posted on 08 March 2005]

Anyone know how I can do bit shifts left and right in aucobol? For instance where binary 0101 when shifted 1 bit left becomes 1010. I don't need a circular shift.

The shift may also be for x number of bits, not necessarily for all bits.
0 Likes
2 Replies
Highlighted
Absent Member.
Absent Member.

RE: [archive] Bit Shifts

solution 1: use a C compiler

move numeric data to a binary type (comp-5, comp-x, unsigned-int)
create small dll accepting dword * parameter for value, dword * for shift. you can return the value as return code. This is easy but may have long term portability issues. rigging up 64 bit is of course also possible (and a little bit more work) usage pointer is a 64 bit binary type.

solution 2: the cobol way
may one small program with the linkage pretty much the same as above (plus the shift mode)

shift left:
evaluate shift
when 0 continue
when 1 multiply value by 2
when 2 multiply value by 4
[...]

since you don'y require wraparound this isn't too much work 🙂

Merlin
0 Likes
Highlighted
Absent Member.
Absent Member.

RE: [archive] Bit Shifts

Originally posted by MerlinM

solution 2: the cobol way
may one small program with the linkage pretty much the same as above (plus the shift mode)

shift left:
evaluate shift
when 0 continue
when 1 multiply value by 2
when 2 multiply value by 4
[...]

since you don'y require wraparound this isn't too much work 🙂

Merlin



Thanks, Merlin, turns out I don't need the shifting right now.
0 Likes
The opinions expressed above are the personal opinions of the authors, not of Micro Focus. By using this site, you accept the Terms of Use and Rules of Participation. Certain versions of content ("Material") accessible here may contain branding from Hewlett-Packard Company (now HP Inc.) and Hewlett Packard Enterprise Company. As of September 1, 2017, the Material is now offered by Micro Focus, a separately owned and operated company. Any reference to the HP and Hewlett Packard Enterprise/HPE marks is historical in nature, and the HP and Hewlett Packard Enterprise/HPE marks are the property of their respective owners.