rotl() 
Author Message
 rotl()


Quote:
> Can someone briefly explain what the function _rotl() does in C?  
> thanks for any insight.

I don't think the function exists in standard C; as far as I know it is a
Microsoft extension.

It rotates its value parameter leftward by the specified number of bits;
_rotr does the same thing in the opposite direction - if you use either,
pay *very* close attention to the rules.

Rotating is particularly handy for isolating a group of bits in the
middle of a value (AND with 0-1-0), then moving them to the low end so
the result is a sensible number (I would guess _rotr is used more often
than _rotl).

If you don't know what any of this means, don't worry about it... you'll
probably never need to know.

        -- AK

--



Fri, 07 Jan 2000 03:00:00 GMT  
 rotl()

Can someone briefly explain what the function _rotl() does in C?  
thanks for any insight.



Fri, 07 Jan 2000 03:00:00 GMT  
 rotl()

Sure, absolutely nothing (in standard C, that is).  This is probably a
compiler extension or an after market library add-on.  It sounds a lot like
the assembly language command rotate left.  I suspect if you peek in your
compiler docs, it may describe the function for you.  If this is some code
that you have inherited, and your compiler does not have a _rotl()
function, you are in a wee bit of trouble.  That's because an assembly
rotate typically also manages the carry bit, which is inaccessible from C.
If you can figure out what the code is doing, perhaps you can do the same
thing with shifts & ands.  You might try a web search for information on
that topic.



Quote:
> Can someone briefly explain what the function _rotl() does in C?  
> thanks for any insight.



Sat, 08 Jan 2000 03:00:00 GMT  
 rotl()



Quote:
>Rotating is particularly handy for isolating a group of bits in the
>middle of a value (AND with 0-1-0), then moving them to the low end so
>the result is a sensible number (I would guess _rotr is used more often
>than _rotl).

In C you would do this with >>

--
-----------------------------------------


-----------------------------------------



Sat, 08 Jan 2000 03:00:00 GMT  
 rotl()



Quote:


> >Rotating is particularly handy for isolating a group of bits in the
> >middle of a value (AND with 0-1-0), then moving them to the low end so
> >the result is a sensible number (I would guess _rotr is used more often
> >than _rotl).

> In C you would do this with >>

Agreed in the context of the paragraph above but be aware
that ">>" is not the same as "rotr"...
 ">>" does not 'wrap' the bit(s) rotated off one end of value to the other
end.

#include <stdio.h>
#include <stdlib.h>
int main (void) {
  printf ("%d\n", _rotr (3, 1));
  printf ("%d\n", 3 >> 1);
  return 0;

Quote:
}

Regards
Brian
Quote:

> --
> -----------------------------------------


> -----------------------------------------



Sat, 08 Jan 2000 03:00:00 GMT  
 rotl()



Quote:
>Can someone briefly explain what the function _rotl() does in C?  
>thanks for any insight.

I don't know, but the ROTFL() function in my compiler invokes odd behavior.


Sun, 09 Jan 2000 03:00:00 GMT  
 rotl()

Quote:



>>Can someone briefly explain what the function _rotl() does in C?  
>>thanks for any insight.

>I don't know, but the ROTFL() function in my compiler invokes odd behavior.

ROTFL()!

Must be a recursive function?

Ken
--


#include <disclaim>



Mon, 10 Jan 2000 03:00:00 GMT  
 rotl()



Quote:


>> Can someone briefly explain what the function _rotl() does in C?  
>> thanks for any insight.

>.....If this is some code
>that you have inherited, and your compiler does not have a _rotl()
>function, you are in a wee bit of trouble.  That's because an assembly
>rotate typically also manages the carry bit, which is inaccessible from C.
>If you can figure out what the code is doing, perhaps you can do the same
>thing with shifts & ands.  You might try a web search for information on
>that topic.

Adding to the confusion, some CPUs (the 8051, for one) give you the
option of rotating through the carry bit or not:
   rl   a  ; rotates the accumulator left - carry bit not included.
   rlc a  ; rotates the accumulator left, cary bit goes to acc LSB,
            ; acc MSB goes to carry.
Additionally, the 8051 has no "shift" instructions - to do a true
shift, you need to AND out the bit that rotated off the other end.

That "wee bit of trouble" can get very hairy very quickly!

Cameron Foster


http://www2.netcom.com/~cdfoster/



Tue, 11 Jan 2000 03:00:00 GMT  
 rotl()


: Can someone briefly explain what the function _rotl() does in C?  
: thanks for any insight.

this is the little brother of the function _rotfl(), which is provided
by some versions of UNIX to allow the user to see the obvious hilarity
you build into a program...

--

UNIX Specialist, Paranet Inc. <--> Raytracing|Fractals|Interactive Fiction
http://www.paranet.com/        \/           Homebrewing|Strange Attractors



Tue, 11 Jan 2000 03:00:00 GMT  
 rotl()

Quote:


> : Can someone briefly explain what the function _rotl() does in C?  
> : thanks for any insight.

> this is the little brother of the function _rotfl(), which is provided
> by some versions of UNIX to allow the user to see the obvious hilarity
> you build into a program...

Note that this function may not be provided on many installations, for
the obvious public health reasons.

--

            http://www.geocities.com/SiliconValley/Lakes/7537/



Tue, 11 Jan 2000 03:00:00 GMT  
 
 [ 10 post ] 

 Relevant Pages 
 

 
Powered by phpBB® Forum Software