Skip to Main Content
IBM Power Ideas Portal


This portal is to open public enhancement requests against IBM Power Systems products, including IBM i. To view all of your ideas submitted to IBM, create and manage groups of Ideas, or create an idea explicitly set to be either visible by all (public) or visible only to you and IBM (private), use the IBM Unified Ideas Portal (https://ideas.ibm.com).


Shape the future of IBM!

We invite you to shape the future of IBM, including product roadmaps, by submitting ideas that matter to you the most. Here's how it works:

Search existing ideas

Start by searching and reviewing ideas and requests to enhance a product or service. Take a look at ideas others have posted, and add a comment, vote, or subscribe to updates on them if they matter to you. If you can't find what you are looking for,

Post your ideas
  1. Post an idea.

  2. Get feedback from the IBM team and other customers to refine your idea.

  3. Follow the idea through the IBM Ideas process.


Specific links you will want to bookmark for future use

Welcome to the IBM Ideas Portal (https://www.ibm.com/ideas) - Use this site to find out additional information and details about the IBM Ideas process and statuses.

IBM Unified Ideas Portal (https://ideas.ibm.com) - Use this site to view all of your ideas, create new ideas for any IBM product, or search for ideas across all of IBM.

ideasibm@us.ibm.com - Use this email to suggest enhancements to the Ideas process or request help from IBM for submitting your Ideas.

Status Not under consideration
Workspace IBM i
Categories Languages - RPG
Created by Guest
Created on Oct 1, 2021

Functions for shift operations - logical, arithmetic and circular ( rotation ) shift

We have many different ways of manipulating bits in RPG via %bitand() %bitor() etc, but I'm missing shift operations on expressions like it is done with %bitand() and %bitor().

it could be a logical shift function %SHL() or %SHR() ( shift left / right ), an arithmetic shift function %SHLA() or %SHRA() ( shift left / right aritmetic) , or a circular shift (rotation) like %ROL() or %ROR() (rotate left/right)

Description for clarification can be found here:
https://en.wikipedia.org/wiki/Logical_shift
https://en.wikipedia.org/wiki/Arithmetic_shift
https://en.wikipedia.org/wiki/Circular_shift#Example

I haven't figured out how to do it with MI instructions but I expect that it is more effective if it is implemented in the RPG language.


Use Case:

For example:

dcl-s uint1 uns(10);
dcl-s uint2 uns(10);

uint1 = 1;
uint2 = %shl(uint1 : 3); // = 8 -- shift left 3 bits


Idea priority Low
  • Guest
    Reply
    |
    Nov 18, 2021

    IBM does not intend to provide a solution to this request at this time, so it is being closed.

    While the suggested RPG built-in functions might be useful for some applications, it is unlikely that they would have broad appeal to RPG programmers in general. And as indicated in the comments, it is possible to write procedures to handle these shift operations.

  • Guest
    Reply
    |
    Oct 14, 2021

    The CEAC has reviewed this requirement and recommends that IBM view this as a MEDIUM priority requirement that should be addressed.

    Background: The COMMON Europe Advisory Council (CEAC) members have a broad range of experience in working with small and medium-sized IBM i customers. CEAC has a crucial role in working with IBM i development to help assess the value and impact of individual RFEs on the broader IBM i community and has therefore reviewed your RFE.

    To find out how CEAC help to shape the future of IBM i, see CEAC @ ibm.biz/BdYSYj and the article "The Five Hottest IBM i RFEs Of The Quarter" at ibm.biz/BdYSZT

    Therese Eaton – CEAC Programme Manager, IBM

  • Guest
    Reply
    |
    Oct 5, 2021

    I agree that adding the prefix "BIT" would make the naming consistent with the bit operations we have now.
    Good point.

    Of course I know that it can be coded using power of two. One of the reasons I set priority to low.
    But this is more ineffective compared to using an MI instruction for the same purpose.

  • Guest
    Reply
    |
    Oct 5, 2021

    Your shift operations can be implemented by multiply and divide with a power of two. However it will be more clear to have it in RPG as directly build in, so I support your RFE.

    Perhaps it would be even more clear if your functions was prefixed by BIT as i.e BITXOR, BITAND, BITAND so it will be

    %BITSHL()
    %BITSHR()
    %BITSHLA()
    %BITSHRA()
    %BITROL()
    %BITROR()

    to complete the list of bitwise operations.

  • Guest
    Reply
    |
    Oct 3, 2021

    As stated in your links... this is nothing more that multiplying/dividing by a power of 2.

    Shift left 3 bits.... uint2 = uint1 * (2 ** bitstoshiftleft);

    If you wish a procedure... unit2 = ShiftLeft(uint1: 3);

    Dcl-Proc ShiftLeft;

    Dcl-Pi *N Uns(20);
    uInt Uns(20) Const;
    bits Uns(10) Const;
    End-Pi;

    Return uInt * (2 ** bits);
    End-Proc;

    ... and your MI code will even be better/faster.