binary

File written by old C code, moved to C#

I'm working on converting an old C program (currently run on UNIX) into our C# system. The program builds some data into several structs and then writes a file using a series of fwrites like this: fwrite ( &loc, sizeof ( struct loc_items ), 1, hdata.fp ); With loc being the data, struct loc_items being the struct it's a type of. M...

C read binary stdin

Hey guys, I'm trying to build an instruction pipeline simulator and I'm having a lot of trouble getting started. What I need to do is read binary from stdin, and then store it in memory somehow while I manipulate the data. I need to read in chunks of exactly 32 bits one after the other. How do I read in chunks of exactly 32 bits at a ti...

Why is (a | b ) equivalent to a - (a & b) + b?

I was looking for a way to do a BITOR() with an Oracle database and came across a suggestion to just use BITAND() instead, replacing BITOR(a,b) with a + b - BITAND(a,b). I tested it by hand a few times and verified it seems to work for all binary numbers I could think of, but I can't think out quick mathematical proof of why this is cor...

converting binary to decimal in ocaml

How could I convert binary to decimal in ocaml in the following, If I am representing binary numbers like the following 01 is [False; True] which equals 2? I want to write a method to return the double of the number in decimal form. For example in this case the method will take in [False; True] and return [False; False, True] which is 4...

converting binary to decimal and decimal to binary in ocaml

How could I convert binary to decimal and decimal to binary in the following, If I am representing binary numbers like the following 01 is [False; True] which equals 2? I want to write a method to take in [False; True] and return 2. Also a method for doing it the other way around taking in an integer 2 and returning [False; True]. ...

Patterns in Binary Numbers

Consider an n-bit binary number in the following form: bn−1bn−2bn−3...b0 Each bi is a single bit in the n-bit binary number. Each bi has one of two possible values: 0 or 1. An example of a 6-bit binary number is: 110011. Inside the computer, integers are represented as binary numbers. For example, the integer 43 can be repre...

C Endian Conversion : bit by bit

I have a special unsigned long (32 bits) and I need to convert the endianness of it bit by bit - my long represents several things all smooshed together into one piece of binary. How do I do it? ...

How exactly do executables work?

I know that executables contain instructions, but what exactly are these instructions? If I want to call the MessageBox API function for example, what does the instruction look like? Thanks. ...

Convert a subnet mask into binary (octets) in vb.net

How can I convert a subnetmask into binary, so I'll end up with 32 digits? I can convert it into Binary, using Convert.ToString(Long-to-convert, 2) But a subnetmask of 255.255.255.0 returns(it returns it without the spaces though): 1111 1111 1111 1111 1111 1111 0 When I want it to be: 1111 1111 1111 1111 1111 1111 0000 0000 ...

convert base64Binary to pdf

I have raw data of base64Binary. string base64BinaryStr = "J9JbWFnZ......" How can I make pdf file? I know it need some conversion. Please help me. ...

How to receive binary data using ASP.NET MVC?

Hi, I'm using ASP.NET MVC controllers for providing RESTful web services. That works just fine for simple data types like string and int. Now I need to send some binary data (like images and video) to this web service. My question is - what data types do I have to use as Action parameters and what else should I be aware of? Thanks! ...

Simple Regex help for C#

I have an unfinished binary file that has some info that I can recover using regex. The contents are: G $12.Angry.Men.1957.720p.HDTV.x264-HDLH Lhttp://site.com/forum/f89/12-angry-men-1957-720p-hdtv-x264-hdl-538403/ L I Š M ,ABBA.The.Movie.1977.720p.BluRay.DTS.x264-iONN Phttp://site.com/forum/f89/abba-movie-1977-...

Recursively sort array to levels

Hi, I've been working on a site that uses binary mlm system. Illustration here So I have a two tables in database, users anad relationships. There is ID and personal data columns in users. Relationships has 4 columns: ID, parentID, childID, pos. Where pos is either left or right. I have succesfully written a function that recursively...

Display unordered list as a horizontal binary tree

Hi, I have a binary tree in unordered list that looks like this: <ul> <li>1 <ul> <li>2 <ul> <li>4 <ul> <li>8</li> <li>--</li> </ul> </li> <li>5</li> </ul> </li> <li>3 <ul> <li>6</li> <li>7</li> </ul> </li> </ul> </li> Where -- is a empty space (to differ ...

java binary search tree

Hello. I have a question about how would I remove a child from a node (root)? Since I can't call remove, if I make the child null, will the children of that child move up? Like, would I just initialize it as null?? Or would I point to the child's child? ...

mysql binary log only log deletes

Hi, Is there any way in MySQL to only log deletes? I tried using the mysql binary log option but unfortunately, there are too many inserts to my database and the file swells instantly. If I let it grow for more than a day or so it will take up all the room on the server. I just want to log deletes for disaster recovery purposes. Any ...

How to retrieve tree nodes children (recursive function help)

I have a binary, the database table of relationships looks like this: +----+----------+---------+-----+ | id | parentID | childID | pos | +----+----------+---------+-----+ | 1 | 1 | 2 | l | | 2 | 1 | 3 | r | | 3 | 2 | 4 | l | | 4 | 3 | 5 | r | | 5 | 4 | 6 | l ...

How to create socket (Binary) server with WCF?

How to create socket-based ( Binary Socket) WCF server server with WCF, C#? What do I need? I need - Open Source Libs Tutorials Blog posts/Articles ...

2's complement example, why not carry?

I'm watching some great lectures from David Malan (here) that is going over binary. He talked about signed/unsigned, 1's compliment, and 2's complement representations. There was an addition done of 4 + (-3) which lined up like this: 0100 1101 (flip 0011 to 1100, then add "1" to the end) ---- 0001 But he waved his magical hands and th...

how to represent out of range number in binary?

In 2 complements I read from wikipedia, the range is from -128 to 127. So I wonder how do we represent 128 in 2 complement as it is out of range above? ...