Solved

Convert 10bit to 16bit int

Posted on 2006-06-10
2
689 Views
Last Modified: 2010-04-16
How can i convert 10bit value to 16 bit int in c#
0
Comment
Question by:obeser
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 10

Accepted Solution

by:
_Katka_ earned 250 total points
ID: 16881438
Hi again, I have answered the question under your previous question.. but to be exact:

1) Endianess is not applied to this example because it's 10-bit number (thus b10...b1 in any case)
2) try to read all the data in buffer (or alternatively the LCM of 10 and 16 bits = 80 bits = 8 bytes per buffer)
3) make a function:

public Boolean GetBit(int bitIndex, List<Byte> bitField)
{
      return (bitField[bitIndex / 8] & (1 << (bitIndex % 8))) > 0;
}

4) go thru the buffer bits step by step:

public List<Int32> Convert10BitTo16Bit(List<Byte> inputBuffer)
{
      Int32 actualValue = 0;
      List<Int32> outputBuffer = new List<Int32>();

      for (int a = 0; a < yourBuffer.Length * 8; a++)
      {
            // every ten bits store the actual 16-bit value
            if (a != 0 && a % 10 == 0)
            {
                  outputBuffer.Add(actualValue);
                  actualValue = 0;    
            }

            // sum the current bit to our actual value
            if (GetBit(a, inputBuffer))
            {
                  actualValue += 1 << (9 - (a % 10));
            }
      }

      return outputBuffer;
}

regards,
Kate
0
 

Author Comment

by:obeser
ID: 16884251
Hi Kate I have graded your solution AA at first look. Because it seems to work. But when i tried to run it
i noticed that it does not work correctly.

1- it does not handle all the buffer you always got 1 member missing. that is
(int a = 0; a < yourBuffer.Length * 8) syntax it does not deal with last 10 bit
2-In conversion i think there is a problem.

if you revise please revise your solution i would be happy.
Ozgur

0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Extention Methods in C# 3.0 by Ivo Stoykov C# 3.0 offers extension methods. They allow extending existing classes without changing the class's source code or relying on inheritance. These are static methods invoked as instance method. This…
In order to hide the "ugly" records selectors (triangles) in the rowheaders, here are some suggestions. Microsoft doesn't have a direct method/property to do it. You can only hide the rowheader column. First solution, the easy way The first sol…
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …
This video shows how to use Hyena, from SystemTools Software, to update 100 user accounts from an external text file. View in 1080p for best video quality.
Suggested Courses

739 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question