GSP
Quick Navigator

Search Site

Unix VPS
A - Starter
B - Basic
C - Preferred
D - Commercial
MPS - Dedicated
Previous VPSs
* Sign Up! *

Support
Contact Us
Online Help
Handbooks
Domain Status
Man Pages

FAQ
Virtual Servers
Pricing
Billing
Technical

Network
Facilities
Connectivity
Topology Map

Miscellaneous
Server Agreement
Year 2038
Credits
 

USA Flag

 

 

Man Pages
std::rotr(3) C++ Standard Libary std::rotr(3)

std::rotr - std::rotr


Defined in header <bit>
template< class T > (since C++20)
[[nodiscard]] constexpr T rotr( T x, int s ) noexcept;


Computes the result of bitwise right-rotating the value of x by s positions. This
operation is also known as a right circular shift.


Formally, let N be std::numeric_limits<T>::digits, r be s % N.


* If r is 0, returns x;
* if r is positive, returns (x >> r) | (x << (N - r));
* if r is negative, returns std::rotl(x, -r).


This overload participates in overload resolution only if T is an unsigned integer
type (that is, unsigned char, unsigned short, unsigned int, unsigned long, unsigned
long long, or an extended unsigned integer type).


x - value of unsigned integer type
s - number of positions to shift


The result of bitwise right-rotating x by s positions.


Feature-test macro: __cpp_lib_bitops

// Run this code


#include <bit>
#include <bitset>
#include <cstdint>
#include <iostream>


int main()
{
const std::uint8_t i = 0b00011101;
std::cout << "i = " << std::bitset<8>(i) << '\n';
std::cout << "rotr(i,0) = " << std::bitset<8>(std::rotr(i,0)) << '\n';
std::cout << "rotr(i,1) = " << std::bitset<8>(std::rotr(i,1)) << '\n';
std::cout << "rotr(i,9) = " << std::bitset<8>(std::rotr(i,9)) << '\n';
std::cout << "rotr(i,-1) = " << std::bitset<8>(std::rotr(i,-1)) << '\n';
}


i = 00011101
rotr(i,0) = 00011101
rotr(i,1) = 10001110
rotr(i,9) = 10001110
rotr(i,-1) = 00111010


rotl computes the result of bitwise left-rotation
(C++20) (function template)
operator<<=
operator>>= performs binary shift left and shift right
operator<< (public member function of std::bitset<N>)
operator>>

2022.07.31 http://cppreference.com

Search for    or go to Top of page |  Section 3 |  Main Index

Powered by GSP Visit the GSP FreeBSD Man Page Interface.
Output converted with ManDoc.