Thread overview
[Issue 8007] New: Wrong documentation for '>>'
Apr 30, 2012
timon.gehr@gmx.ch
May 02, 2012
Don
May 02, 2012
timon.gehr@gmx.ch
April 30, 2012
http://d.puremagic.com/issues/show_bug.cgi?id=8007

           Summary: Wrong documentation for '>>'
           Product: D
           Version: D2
          Platform: All
        OS/Version: All
            Status: NEW
          Severity: normal
          Priority: P2
         Component: websites
        AssignedTo: nobody@puremagic.com
        ReportedBy: timon.gehr@gmx.ch


--- Comment #0 from timon.gehr@gmx.ch 2012-04-30 11:18:01 PDT ---
http://dlang.org/expression.html#ShiftExpression claims:

"<< is a left shift. >> is a signed right shift. >>> is an unsigned right shift."

This is false. '>>' is an unsigned right shift for unsigned types.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
May 02, 2012
http://d.puremagic.com/issues/show_bug.cgi?id=8007


Don <clugdbug@yahoo.com.au> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |clugdbug@yahoo.com.au


--- Comment #1 from Don <clugdbug@yahoo.com.au> 2012-05-02 08:32:33 PDT ---
I guess you mean it makes you think that x >> 1 is

(cast(signed!(typeof(x)))x) >> 1

and that x >>> 1 is

(cast(unsigned!(typeof(x)))x) >> 1

?

Both of which are untrue.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
May 02, 2012
http://d.puremagic.com/issues/show_bug.cgi?id=8007



--- Comment #2 from timon.gehr@gmx.ch 2012-05-02 10:46:16 PDT ---
(In reply to comment #1)
> I guess you mean it makes you think that x >> 1 is
> 
> (cast(signed!(typeof(x)))x) >> 1
> 

Yes, as it is phrased, -1U >> 1 == -1U would have to hold. The bug report is about this.

> and that x >>> 1 is
> 
> (cast(unsigned!(typeof(x)))x) >> 1
> 
> ?
> 
> Both of which are untrue.

We should fix >>> or get rid of it.
The usual integral promotion rules are an extremely bad fit here.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------