Jul.18.2018 -- CAlive to introduce a bit rotate operators and assignment operators

10 views
Skip to first unread message

Rick C. Hodgin

unread,
Jul 18, 2018, 10:32:46 AM7/18/18
to CAlive Programming Language
CAlive will introduce the ability to rotate the bits in a value using the <<< and >>> syntax for rotate right and left.  In addition, sub-bit portions within can be rotated using the more complex forms of <<start#length#Nn<< and >>start#length#Nn>>.

These forms are also extended to assignment operators using a trailing equal sign, as in <<<= and >>>=, as well as <<start#length<<= and >>start#length>>=.

    x <<<= 5;            // Rotate left 5 bits
    y >>>= 5;            // Rotate right 5 bits

    z = 3 + (x <<< 5);   // Use the left-rotated value of x 5 bits as an operator
    q = 9 - (x >>> 2);   // Use the right-rotated value of x 2 bits as an operator

    a <<7#4<<= 3;         // Rotate the second nibble left by 3 bits
    b >>7#2>>= 1;         // Rotate the upper 2 bits of the second nibble right by 1 bit

-- 
Rick C. Hodgin

Reply all
Reply to author
Forward
0 new messages