RAD Studio |  |

_lrotl, _lrotr

Header File

stdlib.h

Category

Math Routines

Prototype

unsigned long _lrotl(unsigned long val, int count);

unsigned long _lrotr(unsigned long val, int count);

Description

Rotates an unsigned long integer value to the left or right.

_Irotlrotates the given val to the left count bits. _lrotr rotates the given val to the right count bits.

Return Value

The functions return the rotated integer:

- _lrotl returns the value of val left-rotated count bits.
- _lrotr returns the value of val right-rotated count bits.

Example
Copy Code

    #include <stdlib.h>
    #include <stdio.h>
    /* function prototypes */
    int lrotl_example(void);
    int lrotr_example(void);
    /* lrotl example */
    int lrotl_example(void)
    {
       unsigned long result;
       unsigned long value = 100;
       result = _lrotl(value,1);
       printf("The value %lu rotated left one bit is: %lu\n", value, result);
       return 0;
    }
    /* lrotr example */
    int lrotr_example(void)
    {
       unsigned long result;
       unsigned long value = 100;
       result = _lrotr(value,1);
       printf("The value %lu rotated right one bit is: %lu\n", value, result);
       return 0;
    }
    int main(void)
    {
       lrotl_example();
       lrotr_example();
       return 0;
    }

Portability

POSIX | Win32 | ANSI C | ANSI C++
| + |  |

Copyright(C) 2009 Embarcadero Technologies, Inc. All Rights Reserved.
What do you think about this topic? Send feedback!