|
-
February 27th, 2003, 09:41 PM
#1
Hi, hard problem for you pareshgh
I got int with a signed number, and i want to split it to array of bytes, in little endian.
any ideas?
-
February 27th, 2003, 10:23 PM
#2
I hope this will help you ( I wrote a console program and tested which will give you the result required,
-------------
// byte representation of a long number
int a = 123456789; //111 01011011 11001101 00010101
byte []b = new byte[4];
b[0] = (byte)(a & 0xFF);
b[1] = (byte)((a & 0xFF00) >>8);
b[2] = (byte)((a & 0xFF0000) >> 16);
b[3] = (byte) ((a & 0xFF000000) >>24);
Console.WriteLine(b[0]);
Console.WriteLine(b[1]);
Console.WriteLine(b[2]);
Console.WriteLine(b[3]);
----------------------
b[0] is and'ing with 255 so get the first byte
b[1] is and'ing only 2'nd byte and rest are zero'ed and then right shifted 8 bytes so as to get byte what's in it.
and so on.
Paresh
-
February 27th, 2003, 11:00 PM
#3
you're a c# gosu
great. thanks 
how you know all that stuff?
-
February 27th, 2003, 11:07 PM
#4
glad that you are happy. thanx
but I am not a guru
-
February 28th, 2003, 09:15 AM
#5
end------------------------------
Programmers aren't born, but are made from hardwork, effort and time.
To be a good one, requires more effort and hardwork.
Therefore N quality programmer = (N*hardwork)+(N*effort)+(N*time)
-
February 28th, 2003, 03:29 PM
#6
-
March 2nd, 2003, 09:45 PM
#7
bahahhahaha..
You know what this thread sounds like..
This thread sounds like a high school kid looking for someone to do his homeowork..

**** some ppl can be so tricksy(LOTR)....
I guess it beats renting a coder at rend a coder web site..
-
March 2nd, 2003, 10:53 PM
#8
-
March 3rd, 2003, 05:42 AM
#9
Hay you guys! Have you ever heart about the windows socket function like: ntohl()? It takes big indian long and conerts it into the little-indian on Intel processors... 
You can import them into the C# and use them...
I know, it is just alternative and the paresh's solution works too...
Martin
-
March 3rd, 2003, 11:43 AM
#10
martin, as you are always informative,
this is a good piece of information.
thanx again,
Paresh
-
March 3rd, 2003, 03:07 PM
#11
Originally posted by MartinL
Hay you guys! Have you ever heart about the windows socket function like: ntohl()? It takes big indian long and conerts it into the little-indian on Intel processors...
You can import them into the C# and use them...
I know, it is just alternative and the paresh's solution works too...
Martin
I dont think underwater would get full marks for his assignment if he used an api function to answer the question...
-
March 3rd, 2003, 03:12 PM
#12
hahaha
lol
he isn't underwater
he is underwar. (with me )
and yes, u r right. he won't get the full marks for his assignement. if i would be his professor i wdn't gave the internet access and then instructed to try on his own

LOL again
take it easy,
Paresh
-
March 3rd, 2003, 06:55 PM
#13
grrr
-
March 4th, 2003, 02:25 AM
#14
Hm... If this is the point (to make things more difficult), I would recommed him to write the routine in LISP and use it in C#...
Or even better, to use monolit microcomputer, write it in assembler and comunicatate with the monolit mc using COM port...   
Martin
-
March 4th, 2003, 02:42 AM
#15
this going crazy.. come on guys i am not gonna college LISP and theoritical programs...
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|