Click here to Skip to main content
15,887,596 members
Home / Discussions / C#
   

C#

 
GeneralRe: is there any binary to decimal convertor class Pin
hotthoughtguy22-Dec-09 10:18
hotthoughtguy22-Dec-09 10:18 
GeneralRe: is there any binary to decimal convertor class Pin
Luc Pattyn22-Dec-09 10:27
sitebuilderLuc Pattyn22-Dec-09 10:27 
GeneralRe: is there any binary to decimal convertor class Pin
#realJSOP22-Dec-09 10:47
mve#realJSOP22-Dec-09 10:47 
AnswerRe: is there any binary to decimal convertor class Pin
DaveyM6926-Dec-09 16:09
professionalDaveyM6926-Dec-09 16:09 
GeneralRe: is there any binary to decimal convertor class Pin
hotthoughtguy26-Dec-09 22:43
hotthoughtguy26-Dec-09 22:43 
Questioncustom shaped windows forms in c# problem Pin
hosseinghazanfary22-Dec-09 7:35
hosseinghazanfary22-Dec-09 7:35 
AnswerRe: custom shaped windows forms in c# problem Pin
Md. Marufuzzaman22-Dec-09 9:26
professionalMd. Marufuzzaman22-Dec-09 9:26 
QuestionStoring 2 bytes in one Pin
Chris Copeland22-Dec-09 5:57
mveChris Copeland22-Dec-09 5:57 
Hey, i've been looking for an effective method of storing 2 byte values within one. Or, two short values within one.

The system I currently use is by embedding an unsafe code to point to a byte value and to cast the relevant data. Here's an example:

byte db, v1, v2;
v1 = 50;
v2 = 80;

unsafe
{
    byte* db_p = &db;
    db_p[0] = (byte)((v1) >> 2);
    db_p[1] = (byte)(((v1) << 6) | (((v2) >> 4)&0x3F));
    db_p[2] = (byte)((v2) << 4);
}


Which stores two values excellently. However, For values below 4 generally, numbers tend to overlap each other. IE, values of v1 = 0, v2 = 0; and v1 = 1, v2 = 1; tend to have the same digit value of db.

I was wondering there were any other methods of storing 2 values of data (bytes) within one single data (I'm using this to remove the necessity for multi-dimensional arrays and large collection objects).

Thank you!
Answercrap Pin
Luc Pattyn22-Dec-09 6:21
sitebuilderLuc Pattyn22-Dec-09 6:21 
GeneralRe: crap Pin
Chris Copeland22-Dec-09 6:25
mveChris Copeland22-Dec-09 6:25 
GeneralRe: crap Pin
Luc Pattyn22-Dec-09 7:58
sitebuilderLuc Pattyn22-Dec-09 7:58 
AnswerRe: Storing 2 bytes in one Pin
harold aptroot22-Dec-09 6:29
harold aptroot22-Dec-09 6:29 
GeneralRe: Storing 2 bytes in one Pin
Chris Copeland22-Dec-09 6:51
mveChris Copeland22-Dec-09 6:51 
GeneralRe: Storing 2 bytes in one Pin
harold aptroot22-Dec-09 6:55
harold aptroot22-Dec-09 6:55 
AnswerRe: Storing 2 bytes in one Pin
J4amieC22-Dec-09 6:35
J4amieC22-Dec-09 6:35 
GeneralRe: Storing 2 bytes in one Pin
Chris Copeland22-Dec-09 6:49
mveChris Copeland22-Dec-09 6:49 
GeneralRe: Storing 2 bytes in one Pin
harold aptroot22-Dec-09 6:52
harold aptroot22-Dec-09 6:52 
GeneralRe: Storing 2 bytes in one Pin
Chris Copeland22-Dec-09 6:57
mveChris Copeland22-Dec-09 6:57 
GeneralRe: Storing 2 bytes in one Pin
harold aptroot22-Dec-09 7:09
harold aptroot22-Dec-09 7:09 
GeneralRe: Storing 2 bytes in one Pin
Chris Copeland22-Dec-09 7:18
mveChris Copeland22-Dec-09 7:18 
GeneralRe: Storing 2 bytes in one Pin
harold aptroot22-Dec-09 7:21
harold aptroot22-Dec-09 7:21 
GeneralRe: Storing 2 bytes in one Pin
Chris Copeland22-Dec-09 7:29
mveChris Copeland22-Dec-09 7:29 
GeneralRe: Storing 2 bytes in one Pin
harold aptroot22-Dec-09 7:48
harold aptroot22-Dec-09 7:48 
GeneralRe: Storing 2 bytes in one Pin
Ben Fair22-Dec-09 11:06
Ben Fair22-Dec-09 11:06 
GeneralRe: Storing 2 bytes in one Pin
harold aptroot22-Dec-09 11:14
harold aptroot22-Dec-09 11:14 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.