www.digitalmars.com         C & C++   DMDScript  

digitalmars.D - shift right with >>>?

reply dennis luehring <dl.soluz gmx.net> writes:
http://rosettacode.org/wiki/Variable-length_quantity#D

ulong value = 0x100;
ubyte[] v = [0x7f & value];
for (ulong k = value >>> 7; k > 0; k >>>= 7)
{
   v ~= (k & 0x7f) | 0x80;
   if (v.length > 9)
   {
     throw new Exception("Too large value.");
   }
}
v.reverse();

while porting this to D i stumple accross the ">>>" - why is that 
allowed in D?
Nov 30 2013
parent Jonathan M Davis <jmdavisProg gmx.com> writes:
On Sunday, December 01, 2013 08:06:26 dennis luehring wrote:
 http://rosettacode.org/wiki/Variable-length_quantity#D
 
 ulong value = 0x100;
 ubyte[] v = [0x7f & value];
 for (ulong k = value >>> 7; k > 0; k >>>= 7)
 {
    v ~= (k & 0x7f) | 0x80;
    if (v.length > 9)
    {
      throw new Exception("Too large value.");
    }
 }
 v.reverse();
 
 while porting this to D i stumple accross the ">>>" - why is that
 allowed in D?
http://dlang.org/expression.html#ShiftExpression http://dlang.org/expression.html#AssignExpression - Jonathan M Davis
Nov 30 2013