Write Compressed UInt32 : int « Data Types « C# / C Sharp

Home
C# / C Sharp
1.2D Graphics
2.Class Interface
3.Collections Data Structure
4.Components
5.Data Types
6.Database ADO.net
7.Date Time
8.Design Patterns
9.Development Class
10.Event
11.File Stream
12.Generics
13.GUI Windows Form
14.Internationalization I18N
15.Language Basics
16.LINQ
17.Network
18.Office
19.Reflection
20.Regular Expressions
21.Security
22.Services Event
23.Thread
24.Web Services
25.Windows
26.Windows Presentation Foundation
27.XML
28.XML LINQ
C# / C Sharp » Data Types » intScreenshots 
Write Compressed UInt32
  


/*
    This file is part of Sunlit World Scheme
    http://swscheme.codeplex.com/
    Copyright (c) 2010 by Edward Kiser (edkiser@gmail.com)

    This program is free software; you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation; either version 2 of the License, or
    (at your option) any later version.

    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License along
    with this program; if not, write to the Free Software Foundation, Inc.,
    51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;

namespace ExprObjModel
{
    public static partial class Utils
    {

        public static void WriteCompressedUInt32(this Stream str, uint u)
        {
            while (true)
            {
                if ((u & ~0x7Fu== 0)
                {
                    str.WriteByte(unchecked((byte)u));
                    break;
                }
                else
                {
                    str.WriteByte(unchecked((byte)((u & 0x7Fu0x80u)));
                    u = (u >> 7);
                }
            }
        }
    }
}

   
    
  
Related examples in the same category
1.Assign value to int variable
2.Call methods from primitive data types
3.Calculating the product of three integers.
4.Comparing integers using if statements, equality operators, and relational operators.
5.demonstrates variablesdemonstrates variables
6.Assing value to int valueAssing value to int value
7.Calculate: int and doubleCalculate: int and double
8.Size of int, double, char and boolSize of int, double, char and bool
9.displays a conversion table of Fahrenheit to Celsiusdisplays a conversion  
   table of Fahrenheit to Celsius
10.Some Operator on int
11.Using Integers
12.Using Variables
13.Convert string value to integer by using the int.TryParse
14.Use CultureInfo int ToString method
15.Integer OverFlow
16.Catch OverflowException Exception
17.Do calculation with int variable
18.Format int in Console.WriteLine
19.Use CultureInfo in int.ToString method
20.Use #, % and in int format
21.int based Fahrenheit and Celsius (Centigrade) Scales
22.int array property
23.Parse int value
24.The precision specifier controls the number of significant digits or zeros to the right of a decimal:
25.Int value To Hex char
26.Get the digit-length of an int value
27.Max/Min for int and double values
28.Read sync safe int 32
29.Write Synch safe Int32
30.Calculate average for a list of integer values with params int[] values
31.Int extension Convert integer to boolean, is it even, is it positive
32.Converts an integer into a roman numeral.
33.Get Ordinal
34.Output with x8 format
35.Int32.MaxValue and Int32.MinValue
36.Convert Bytes To UInt
37.Compress UInt
38.Decompress UInt
39.Read Compressed UInt32
40.Compress Int
41.Is even
java2s.com  | Contact Us | Privacy Policy
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.