Dear all,
Is there a logic shift operator in C++? I tried ">>", it is an
arithmetic shift operator.
Thanks!
Andy 9 3914
<yu******@gmail.comwrote:
>Dear all,
>Is there a logic shift operator in C++? I tried ">>", it is an arithmetic shift operator.
No, there is no builtin logical shift right.
Steve
Steve Pope posted:
>>Is there a logic shift operator in C++? I tried ">>", it is an arithmetic shift operator.
As far as I know, it's implementationdefined as to whether it's logical
shift or arithmetic shift.
No, there is no builtin logical shift right.
You could probably make one yourself by using a combination of things:
(1) Macros to determine whether the system is signmagnitude, one's
complement or two's complement.
(2) Usage of the IMAX_BITS macro (you can do a Google Groups search for
this.)
(3) Usage of bitwise operators.
It wouldn't be a mammoth task.

Frederick Gotham yu******@gmail.com writes:
Is there a logic shift operator in C++? I tried ">>", it is an
arithmetic shift operator.
It's arithmetical or logical depending on whether or not the integer
you are shifting is signed or not.
Jens
"Jens Theisen" writes:
>Is there a logic shift operator in C++? I tried ">>", it is an arithmetic shift operator.
It's arithmetical or logical depending on whether or not the integer
you are shifting is signed or not.
Actually, there is an established meaning for those two phrases.
Hint: The operation performed does not depend on the value of the operand.
osmium wrote:
"Jens Theisen" writes:
>>Is there a logic shift operator in C++? I tried ">>", it is an arithmetic shift operator.
It's arithmetical or logical depending on whether or not the integer you are shifting is signed or not.
Actually, there is an established meaning for those two phrases.
Yes, and they mean exactly the same thing when applied to unsigned integers.

Clark S. Cox III cl*******@gmail.com
"Clark S. Cox III" writes:
osmium wrote:
>"Jens Theisen" writes:
>>>Is there a logic shift operator in C++? I tried ">>", it is an arithmetic shift operator. It's arithmetical or logical depending on whether or not the integer you are shifting is signed or not.
Actually, there is an established meaning for those two phrases.
Yes, and they mean exactly the same thing when applied to unsigned
integers.
The hardware instruction repertoires that I know of that provide both
arithmetic and logical shifts have four shift instructions, not three.
Unless you are terribly clever it is going to take longer to force a
preliminary step of seeing what the value of the operand is, before doing
the shift. YMMV.
osmium wrote:
"Clark S. Cox III" writes:
osmium wrote:
"Jens Theisen" writes:
>
Is there a logic shift operator in C++? I tried ">>", it is an
arithmetic shift operator.
It's arithmetical or logical depending on whether or not the integer
you are shifting is signed or not.
Actually, there is an established meaning for those two phrases.
Yes, and they mean exactly the same thing when applied to unsigned
integers.
The hardware instruction repertoires that I know of that provide both
arithmetic and logical shifts have four shift instructions, not three.
Unless you are terribly clever it is going to take longer to force a
preliminary step of seeing what the value of the operand is, before doing
the shift. YMMV.
What are you talking about hardware instruction repertoires for? I was
simply pointing out that, for unsigned integers, arithmetic and logical
shifts are 100% identical; There is no sign bit to sign extend; there is
no decision to be made.

Clark S. Cox III cl*******@gmail.com
osmium wrote:
"Jens Theisen" writes:
>>Is there a logic shift operator in C++? I tried ">>", it is an arithmetic shift operator.
It's arithmetical or logical depending on whether or not the integer you are shifting is signed or not.
Actually, there is an established meaning for those two phrases.
Hint: The operation performed does not depend on the value of the operand.
No, but on the type.
Hint: "singned"/"unsigned" doesn't say anything about the value.
osmium wrote:
"Clark S. Cox III" writes:
>osmium wrote:
>>"Jens Theisen" writes:
Is there a logic shift operator in C++? I tried ">>", it is an arithmetic shift operator. It's arithmetical or logical depending on whether or not the integer you are shifting is signed or not.
Actually, there is an established meaning for those two phrases.
Yes, and they mean exactly the same thing when applied to unsigned integers.
The hardware instruction repertoires that I know of that provide both
arithmetic and logical shifts have four shift instructions, not three.
Really? I don't know many, but those that I know only have three, because
there is no difference between a logic and an arithmetic left shift, but
there is one for the right shift. Sometimes, however, there are two
different names on assembler level for the left shift that just resolve to
the same instruction. This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Mehta Shailendrakumar 
last post by:
Hello,
Can anyone suggest me operator to perform arithmetic shift in C?
May it be for a perticular compiler.
Thank you in advance.
Regards,
Shailendra

by: Simon Johnson 
last post by:
Is there an inbuilt circular shift operator in c#?
I've googled it but because c# happens to be musical note.. i get a
large noise to signal ratio :P
Simon.

by: Kevin 
last post by:
I was looking through some source code and noticed the used of the C# <<
operator. Why is this being used here and under what circumstances is an
leftshift operator useful.
internal enum...

by: Chua Wen Ching 
last post by:
Hi,
I had some beginner questions. Do we need Shift << >> or Logical AND OR XOR operator in our daily programming?
I am not sure why i need to use it? I had some samples of c# codes using it.
...

by: Markus Hahn 
last post by:
While coding some binary data handling I found this IMHO strange behavior:
Dim bToShift As Byte = 1
bToShift <<= 9
Console.WriteLine("and the value is {0}", bToShift)
The output is "2", I...

by: ERE 
last post by:
Pardon me if this has been asked a million times  but I thought that
because of generics, the right shift operator was supposed to change with C#
2.0. I thought it was supposed to change from...

by: LinuxGuy 
last post by:
Hi,
I want to add bits to present number. Shift operator pushes bits and
add '0' at the end.
I want to shift bits and want to add 1 at end
Ex,
1)

by: Nishu 
last post by:
Hi All,
Could you please explain whether C standard supports logical right
shift operation using some operator?
I know somewhere I read about >>operator. I thought, it is in C but i
think i'm...

by: Bob Altman 
last post by:
Hi all,
I want to write a generic class that does this:
Public Class X (Of T)
Public Sub Method(param As T)
dim x as T = param >3
End Sub
End Class

by: isladogs 
last post by:
The next online meeting of the Access Europe User Group will be on Wednesday 6 Dec 2023 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM).
In this month's session, Mike...

by: veera ravala 
last post by:
ServiceNow is a powerful cloudbased platform that offers a wide range of services to help organizations manage their workflows, operations, and IT services more efficiently. At its core, ServiceNow...

by: VivesProcSPL 
last post by:
Obviously, one of the original purposes of SQL is to make data query processing easy. The language uses many Englishlike terms and syntax in an effort to make it easy to learn, particularly for...

by: jimatqsi 
last post by:
The boss wants the word "CONFIDENTIAL" overlaying certain reports. He wants it large, slanted across the page, on every page, very light gray, outlined letters, not block letters. I thought Word Art...

by: isladogs 
last post by:
The next Access Europe meeting will be on Wednesday 7 Feb 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:30 (7.30PM).
In this month's session, the creator of the excellent VBE...

by: fareedcanada 
last post by:
Hello I am trying to split number on their count. suppose i have 121314151617 (12cnt) then number should be split like 12,13,14,15,16,17 and if 11314151617 (11cnt) then should be split like...

by: stefan129 
last post by:
Hey forum members, I'm exploring options for SSL certificates for multiple domains. Has anyone had experience with multidomain SSL certificates? Any recommendations on reliable providers or specific...

by: egorbl4 
last post by:
Скачал я git, хотел начать настройку, а там вылезло вот это
Что это? Что мне с этим делать?
...

by: MeoLessi9 
last post by:
I have VirtualBox installed on Windows 11 and now I would like to install Kali on a virtual machine. However, on the official website, I see two options: "Installer images" and "Virtual machines"....
 