Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import std.traits;
- import std.stdio;
- static ubyte[] packVarint( ulong value )
- out( arr )
- {
- writeln( "Inside of out contract: value=", value, " type=", typeid( typeof(value) ), " result=", arr );
- }
- body
- {
- writeln( "Inside of body: value=", value, " type=", typeid( typeof(value) ) );
- ubyte[] res;
- immutable ubyte maximal = 0b_1000_0000;
- while( value >= maximal )
- {
- res ~= cast( ubyte )( value | maximal );
- value >>= 7;
- }
- res ~= cast(ubyte) value;
- return res;
- }
- void main()
- {
- writeln("works:");
- packVarint( 1 );
- writeln("not works:");
- packVarint( 300 );
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement