Click here to Skip to main content
15,900,616 members
Everything / Binary

Binary

binary

Great Reads

by Christ Kennedy
A graphically bouncy and colorful version of the popular numbers tile-sliding game
by honey the codewitch
BinaryReader and BinaryWriter can be used to parse or write binary files more easily and in a portable manner
by Member 13376231
An overview of a tricky binary collision example when there are multiple definitions of symbols in linked binaries
by PIEBALDconsult
I wasn't going to publish this version, but I just used it a second time, so maybe someone else will need it too. This is very much like the second version above except that it uses a non-generic IList. Today, I used this to find and insert TreeNodes in a TreeNodeCollection, yesterday I used it...

Latest Articles

by Jovibor
Library for parsing internal structures of PE32/PE32+ binary files.
by Member 13376231
An overview of a tricky binary collision example when there are multiple definitions of symbols in linked binaries
by Christ Kennedy
A graphically bouncy and colorful version of the popular numbers tile-sliding game
by honey the codewitch
BinaryReader and BinaryWriter can be used to parse or write binary files more easily and in a portable manner

All Articles

Sort by Title

Binary 

8 Feb 2017 by JeezyWonder
Hi,Im working with EEPROM now, i send data though serial port to it, and EEPROM waits from data 24 bits, the first 8bits - EEPROM understand as address where to write sending data, the antoher 16bits - its what to write.So im confused how make it happen in C# code.Update:Ok, im using...
8 Feb 2017 by Richard MacCutchan
serialPort1.Write("\u0001"); // 5 bytesNo that is 2 bytes x00 and x01.In your comments you say you want to send "4001" to 25 memory cell in EEPROM. Using hex notation would make this clearer:byte[] bData = new byte[]{ 0x40, 0x01 };byte[] bAddress = new byte[] {...
10 May 2018 by Member 13822063
Hey all, I'm a student and doing a practice for my exam. I will have to create a program that converts an input into binary. So far, I got the code working BUT I need my output to be in reverse order. I used [::-1] yet it doesn't seem to be doing it. Thanks! What I have tried: def...
10 May 2018 by Thomas Daniels
output is always just a one-letter string (because it's inside the loop), so reversing it just gives the same string. What you need to do, is reversing the whole string before printing it: def binary_converter(num): reverse = "" while num != 0: output = num % 2 # 0 or 1 ...
16 Jan 2012 by Simon Bridge
Multiple-file, searchable, streaming compression library implemented natively in .NET.
10 Nov 2015 by OriginalGriff
It's e): Do your own homework.We do not do your homework: it is set for a reason. It is there so that you think about what you have been told, and try to understand it. It is also there so that your tutor can identify areas where you are weak, and focus more attention on remedial...
23 Jan 2019 by Ray K
Extending BinaryReader/Writer to support a different byte order, string and date formats, and advanced navigation in binary files
7 Feb 2022 by shri harshan
Sample input: 123 13 4 Sample output: 202 What I have tried: a = int(input()) b = int(input()) c = int(input()) len_a = len(a) len_b = len(b) s = '' diff = abs((len_a-len_b)) for i in range(1,diff+1): s+='0' if len_a
7 Feb 2022 by Richard MacCutchan
Once you have the integer values you can simply add them together to get the total. This holds true for any number. The key to your question is how to display them in the correct format. You need to use the base number to calculate each digit...
7 Feb 2022 by OriginalGriff
This is the same question you asked yesterday: Add two numbers given in base n format in python.[^] And since I told you exactly what to do then and you've ignored it, there is no point at all in asking it again. If I was you, I'd spend the...
6 Feb 2022 by shri harshan
sample input: 123 13 4 sample output: 202 If the input is given in negative value print "Invalid input". What I have tried: a = input() b = input() c = input() d = ((a+b),4) print(d)
6 Feb 2022 by OriginalGriff
Use the int(string, base) function to translate input from a base n to internal binary, add them, then convert back to the appropriate base to display: Python int() Function[^]
5 May 2021 by Blake Miller
I have two PML files. One from a system that 'works' and one from a system that does not. I want to compare the two PML files and find the 'differences', which could indicate why the system that is broken, is broken. There are hundreds of 'false...
4 May 2021 by Rick York
Have you had a look at these ? procmon-parser · PyPI[^] GitHub - asquigglytwist/SeeBee: A PML Analyzer.[^] This might be helpful also : The Ultimate Guide to Procmon[^]
16 Sep 2013 by ellasaro
So I have this weird problem,I wrote a program in Visual Studio 2010.At first I configured it so the binary would have an icon, lets call it icon A. Then I changed the configuration again and changed the icon to icon B. The problem is that if I copy/move my binary to my desktop the...
17 Sep 2013 by DaveyM69
Have you had a look at this[^]?
27 Sep 2012 by mayaSage
Hello,Anyone has any idea how I can convert an audio file into binary code? Are there any programs I can use?Thank you,MayaSage
27 Sep 2012 by Sergey Alexandrovich Kryukov
The question makes no sense. Everything is "binary", including your original audio file.[EDIT]After OP's (incomplete) clarification:I can only guess that you need to represent the waveform and do some image recognition, but it all depends on what you have and what you want —...
1 Oct 2012 by Member 4643583
I am trying to develope delta file synchronization application which work over network. Please suggest me which is best algorithm for generation of patch file or delta file. Please give me best algorith between xdelta, zdelta, vcdiff or other with its advantage.
15 Mar 2013 by johngorman1
I'm starting a new application to search a text file with up to 12000 items for a given term and also allow a depth to be specified.My application requirements are as folllows:A word search tree that allows:1.Parse a text file and build the tree.2. Allow a depth to be specified3....
15 Mar 2013 by Sergey Alexandrovich Kryukov
Thank you for clarification of the question. In this case, you really need to implement one or another kind of a search tree:http://en.wikipedia.org/wiki/Search_tree[^],http://www.drdobbs.com/database/ternary-search-trees/184410528[^].For space efficiency and simplicity, a ternary search...
17 Jul 2016 by mannour85
Hi, I need your help;if possible I'm looking for tutorials that help me understand the binary structure of a Word file : a detailed analysis of the structure( the header block of the file, the other block, their beginning, their purpose etc).thank you very much in advance for your...
17 Jul 2016 by Kornfeld Eliyahu Peter
You may spend years with that...I would ask why? It is an old format and going out of use...In any case, start reading here: Understanding the Word .doc Binary File Format[^]
17 Jul 2016 by Dave Kreskowiak
Why?The format has been "dead" for quite a while now. You're not going to find a "tutorial" on it.You will, however, find documentation on it. Google results[^]
4 Jan 2018 by Amedora Ahmed
I am reading binary data image from a serial port device how can i write it to a black and white image file. The project is a bill counting machine which solution. the device scans images of serial number of bill counted including the data counter Below is the data returned from the device as...
4 Mar 2012 by vaidyan
hai,how can i store and retrieve a binary file(fingerprint template file) in sql server in c#.netthanks in advance!
4 Mar 2012 by Uday P.Singh
Try this:Save-and-Retrieve-Files-from-SQL-Server-Database-using-ASP.Net[^]hope it helps :)
4 Mar 2012 by OriginalGriff
Set up a varbinary or image column in your database.Then just insert it: using (SqlConnection con = new SqlConnection(strConnect)) { con.Open(); byte[] bytes = GetTheByteData(); using (SqlCommand com = new...
4 Mar 2012 by Mohammad A Rahman
Hope it helps,How to store and fetch binary data into a file stream column[^]:)
5 Mar 2012 by Felipe Gentil
One more tutorial here :)http://codeabout.wordpress.com/2012/03/02/saving-files-into-your-sql-database-with-c/[^]
4 Feb 2018 by Member 13661441
can we use the name of the class instead of its object in the following syntax : student s; fin.read((char*)&s,sizeof(s)); where s is the object of the class. and student is the mane of the class What I have tried: Basically nothing,
4 Feb 2018 by CPallini
Yes you can. The compiler happily accetps fin.read((char*)&s,sizeof(student)); As you may easily verify. The form fin.read((char*)&s,sizeof(s)); however is more robust (if you change the type of s it remains correct).
16 Apr 2014 by Member 10754683
Studying for finals and came across a question on an old exam which I have no idea how to approach. How do I tell right away if something NP complete? I don't know the first step to answering this.A = nxn binary matrix b = element in Z^nand I need to find out if there is an x such that x...
4 Jul 2021 by KarNullKa
I found a project mono/decimal.c at ee90d5ff1d521f92c3dd9cca79b002dc4bc65ee3 · mono/mono · GitHub[^] where there are methods of mathematical operations with different values. But I need help with a row sub192(rlo, rmi, rhi, 0, tlo, thi, &rlo,...
4 Jul 2021 by OriginalGriff
To answer that, we'd have to do all the donkey work - a good hard look at what is a pretty-much undocumented project that few of us would have much need for. Why would you assume we'd want to do that for no good reason? Ask the original author:...
5 Jul 2021 by KarNullKa
The line I asked about is correct.It doesn't subtract the same parameters like lo, mid, hi because the values need to be shifted to subtract the highest part of the number. Therefore, the method sub192(rlo, rmi, rhi, 0, tlo, thi, &rlo, &rmi,...
28 Sep 2014 by suleman115
Hi i am implementing binary search in c#, here is the codeint[] a={1,3,4,5,7,9,10};int max=6;int min=0;int target=1;while(max>=min){ if((max+min)!=0) { int mid=(max+min)/2; if(a[mid]==target) { Console.Write(a[mid]); min=max; } ...
28 Sep 2014 by gopesh2010
Try removing equal from while(max>=min)So change while(max>=min) to while(max>min)
28 Sep 2014 by suleman115
I should just make the min=max+1 when i find target, here:int[] a={1,3,4,5,7,9,10};int max=6;int min=0;int target=1;while(max>=min){ int mid=(max+min)/2; if(a[mid]==target) { Console.Write(a[mid]); min=max+1; } else if(a[mid]>target)...
25 Aug 2019 by higii
Trying to learn about Binary Tree while preparing for an exam, and I came across this code. And even tho it looks like it makes sense I simply cannot understand the purpose of this and how it actually works, so can anyone please elaborate? And this is the code : space += 5; ...
25 Aug 2019 by RickZeeland
Here is a tutorial: Binary trees - Learn C - Free Interactive C Tutorial[^] And here is a nice explanation: binary-search-trees-explained-5a2eeb1a9e8b[^]
28 Nov 2015 by Member 12137990
if(input.is_open() && output.is_open()) { while(!input.eof()) { char a=NULL; getline(input,line); while(!line.empty()) { int num=0; string byte=line.substr(0,8); for(int...
28 Nov 2015 by User 59241
The best way to convert binary string to number are the stoXX functions.http://www.cplusplus.com/reference/string/stoi/[^]So:#include #include int main(){ const std::string bitstr = "00001111"; int intval = std::stoi(bitstr, 0, 2); std::cout
19 Nov 2011 by T0mii
My program is crashing when i try to delete the largest number, can some one help me please? I really dont know any further i tried my best. Here is the code please some one help:#include #include #include using namespace std; template class...
19 Nov 2011 by T0mii
fixed it, i was over thinking it, cause i just need to delete the largest number in my tree and that wont have a right childe, and then i only have to replace it with the left childe if he got one and delete it, it works perfect, ty everyone who helped me, trough this project.Here is the...
18 May 2013 by ronnie1stpla
hey everybody!i'm working on a code which its purpose is to print all the nodes in an ordinary binary tree, ,which their value is an odd number.if i will travel the tree's nodes by an Inorder , the running time will be 0(n) ,(where n is the number of the total nodes in the...
18 May 2013 by Mehdi Gholam
If you are iterating over all the tree then just create a list of the values and go over that and get the odd values O(n).
19 Mar 2020 by honey the codewitch
BinaryReader and BinaryWriter can be used to parse or write binary files more easily and in a portable manner
16 Feb 2015 by Member 11456611
So i have an array for example 4,3,17,5,1,2and the output should be: 17-1=16 since it is the max difference between the numbers.i figured it out how to do it, but what I don't understand is, why my teacher is telling me to sort the array and to apply binary search, it should be O(nlogn). I...
16 Feb 2015 by KarstenK
Sorting algorhitm have different complexitiy. In the wikipedia you find some explanations.If you have sorted data you can take the first and the last element. And you are done.Your teachers wants you to learn about it. :-O
9 Mar 2016 by Rupam Bhaduri Pro
Input: 1.0011Output: Valid---------------------Input: 20.1001Output: Invalid------------------------* Floating point number should contain only zeros and ones and a point(.)* I have to do some calculation with that number, so if you convert it to char array then please convert it...
9 Mar 2016 by OriginalGriff
So stop converting it to a number and start by validating the string.Create a bool value "hasPoint", and set it to false.loop through the input string, examining each character in turn.If it is a '0' or a '1', then it's fine.if it's a '.', then check "hasPoint" if it's false, then set it...
9 Mar 2016 by Jochen Arndt
The simplest solution would be checking the string (the characters) when the number is entered (as stated in the question):bool bResult = (*input != 0);int decPoint = 0;while (bResult && *input){ switch (*input) { case '.' : decPoint++; case '0' : case '1' :...
8 Jun 2015 by JasonLai1991
how to i scan for a particular 'pattern' of a picture file using c#?I am able to scan for the header and trailer of the file using the binaryReader.when the header has been extracted, I will compare it with the header code in the local database, and it will return the designated file...
8 Jun 2015 by Sergey Alexandrovich Kryukov
I have no idea what makes you thinking that you can identify the source of some image by capturing some specific pattern. I don't think so. And of course the expression "hex pattern" is absurd: "decimal" or "hexadecimal" is just the artifact of string representation of some numeric data in...
10 Jan 2012 by GabeA
I am currently working on a program that receives UDP packets of size 1460 bytes per packet and continuously streams the bytes to the hard drive of my PC. Currently, my program can only receive and stream 84 packets before data loss occurs. I need my program to be realtime with a fast sampling...
10 Jan 2012 by Richard MacCutchan
Why are you messing about with the data in this way? You receive a stream of bytes from the network so all you need to do is write that stream (whatever length you receive) to the disk. Don't try converting to a string (what does that achieve?) and don't write four bytes as an int.
10 Jan 2012 by CodyDaemon
I few things which should help on the speed front...Open the file and keep it open, and just write data to it as it comes in, and then close the file when the program exits. Open and closing files for each packet is just overhead which can easily removed.Why are you writing each 'int' by...
22 Aug 2012 by rtz87
how can i write a program in c# that searches for a string in a string array using binary search technique.with linear it was pretty easy but with binary search it becomes complicated.the only hint i got was that the list has to be sorted first.i completely have no idea how to achieve this.pllzz...
22 Aug 2012 by Kenneth Haugland
There are a couple of good articles about it on the codeproject site:http://www.codeproject.com/search.aspx?q=binary+search&x=13&y=9&sbo=kw[^]If you cant find anything here you should have a look at Google[^]. In the future you should try it yourself first, before you ask :)
22 Aug 2012 by ridoy
http://www.dotnetperls.com/array-binarysearch[^]
29 Apr 2017 by Member 13161564
I have a Binary Search Tree, some functions in it, not planning to use any other libraries, nor use vectors, I have to use arrays and a tree. This code will mostly work, except for a bug, that for some roots, the functions that add arrays wont work or the printing functions wont work. Basically...
29 Apr 2017 by OriginalGriff
Development is not a case of "write it, compile it, fix compiler errors, compile it, ship it" - just compiling does not mean your code is right! :laugh: Think of the development process as writing an email: compiling successfully means that you wrote the email in the right language - English,...
29 Apr 2017 by Patrice T
Quote: No errors, compiles fine. "Compiles fine" means that your code is correct C++, it does not mean that it does what it should as "no error" would mean. "The cat is flying high in the sky.' is correct English grammar, but it is non sense. Quote: Tried debugging, but I'm a novice and it got...
21 Mar 2013 by Alamgirable
Where is the best place to start working with data compression in c++.I want to compress data ontwo endpoints on one endpoint i want to compress data and on other i want decompress.Please help me.
21 Mar 2013 by Saurabh.Garg
I used this one for my C++ projects:Zip Utils - clean, elegant, simple, C++/Win32[^]-Saurabh
21 Mar 2013 by Matthew Faithfull
There are two things here, working with data compression and working with C++. To crack data compression you'll nee to understand the mathematics and algorithms at least reasonably well from a theoretical point of view, in other words on paper. A quick search tells me I might start somewhere...
28 Sep 2011 by Trevor Pickens
For part of a class assignment I must play around with this code for a max heap, and then convert that sorting order so that the smallest numbers, rather than the largest numbers are at the top. For example, all numbers under 100 are children of that node, and should be under that number 100...
28 Sep 2011 by Stefan_Lang
At a glance, I'd say you should change void add(HeapNode * child) { // if the new value is bigger than this value if(child->value > value)to void add(HeapNode * child) { // if the new value is smaller than this value if(child->value
15 Jul 2014 by Member 10947632
Hi, I have following issue in calculating the number of available subnets (or hosts) in network. For example the main subnet is /24 (255.255.255.0) which contains two /25 (255.255.255.128) or four /26 (255.255.255.192).So if the one node is already being used there will be only one /25 or...
15 Jul 2014 by Mehdi Gholam
Start here :http://www.mindwerks.org/Subneting.htm[^]https://learningnetwork.cisco.com/thread/21527[^]a working version : http://sourceforge.net/projects/subntcalc/[^]
7 Jul 2015 by Mohan_J
hi, i used the following html, embedded css to send a html email. That email contains an image to be displayed with div element with help of embedded css style. I can't able to see image in the email client. Please refer below link to my html and css...
7 Jul 2015 by Sergey Alexandrovich Kryukov
You will need to use content-type "text/html" for the whole e-mail or some of its parts in case of multi-part e-mail. CSS can be embedded exactly as in stand-along HTML.Embedding an image is more tricky. You need to create a multi-part e-mail. Let's say, one part is the image, which has...
17 Mar 2022 by Aniket Mani
Question---> Print a single base-10 integer that denotes the maximum number of consecutive's 1 in the binary representation of N. Here, N == (input given by the user) My approach--> #include int main(){ int n,count=0,max=0; ...
17 Mar 2022 by OriginalGriff
The bitwise operators you want to look at are AND: & and SHIFT RIGHT: >> If you AND a number with 1, you get either 0 or 1 depending on eth status of the bottom bit. If you SHIFT RIGHT a number, you move each bit down: 010101 becomes 001010, then...
17 Mar 2022 by Greg Utas
if(n & 0x01) will be true if n is odd (ends in a "1" bit). And n >>= 1 will shift n right by one bit, dropping off the low-order bit so that you can check the next one. The rest is up to you.
17 Mar 2022 by Patrice T
Quote: I know this code is already very optimized as It takes O(log n) time. Indeed, but you take the 1 bit at the time approach. Your code runtime depend on position of leftmost bit set to 1. Bitwise approach can lead to much more optimized...
17 Mar 2022 by Rick York
You can take at least two approaches to the bitwise algorithm : either shift the data or shift the mask. Here is an example that shifts the mask : typedef unsigned int UINT; typedef unsigned char UCHAR; void UnpackBits( UINT value, UCHAR...
16 Oct 2014 by Member 11042100
Hi I have to display student image on image box while selecting student ID from drop down list. The image is store in binary format in db.I want to display the image without using generic http handler. While using the given below code generation one error. The error is "Cannot convert type...
16 Oct 2014 by Nihar Ranjan Sahu
Try this:byte[] toBytes = Encoding.ASCII.GetBytes(somestring);
16 Oct 2014 by OriginalGriff
You can't convert a string to a byte array directly, because a string is (normally) made of unicode characters, which don't "map" directly to single bytes - they are variable length values.You can do it, but you have to tell it explicitly what type of data the string contains:string s =...
7 Aug 2012 by Michelle Phoenix
Hi all,I am busy writing an application that displays the generated images from a barcode library I found on Code Project. The library is quite smart, and will return good errors if something goes wrong, like wrong encoding type selected etc.However, I don't know how to bubble the...
7 Aug 2012 by Sergey Alexandrovich Kryukov
Please see my comment to the question: you really need to learn how exception work. They have nothing to do with your understanding of "errors". Please don't consider my answer as an attempt to resolve your problem: it is not possible before you learn things properly.But, to start with:...
24 Oct 2012 by Member 9244437
I have a binary file containing 0s and 1s. It is 1.8 gb in size. I suspect it is a video file. I don't know how it got stored as 0s and 1s. How can I try some ways of finding out if it is a video file? currently it has extension of txt. It is in a linux directory. Can changing extension help?
24 Oct 2012 by CPallini
If it is actually a video file then, yes, the 'change-extension' trick could work.
25 Apr 2013 by Mohammad Mahdi Nejati
i agree with you ! but that what our professor told us ! so the question is if it not in the first byte where it is? by the way thank;)
25 Apr 2013 by Mohammad Mahdi Nejati
our multi media professor gave us a mkv file and told us that it have a region code on its first byte of the file ! we should change this region code to 0 so that we could play it on any region ! the problem is when i change the first byte of the file get corrupted ! i think that te region code...
25 Apr 2013 by OriginalGriff
it is entirely possible that what you are writing is causing the problem: you aren't writing a zero byte, you are writing a '0' character which is a very different value.Try this instead:file
15 Feb 2012 by Muhammad Idrees GS
Hi,I am developing a client/server application in c#.net. Now I am going to pick the communication mechanism use in client/server packets. I want to know, what will be the best format for sending and receiving data on sockets. Xml serialize or Binary serialize(i am using Marshalling,...
15 Feb 2012 by Sergey Alexandrovich Kryukov
I'm not sure you can save too much of CPU time on custom marshaling compared to a binary serializer.However, you can potentially squeeze some extra performance, mostly by reducing redundancy. You can do it if you build you application-level protocol based on specialized and relatively rigid...
15 Feb 2012 by Mehdi Gholam
Check out my article fastJSON[^] Which is faster than XML and Binary serialization and is as robust as Binary for polymorphic data.
15 Feb 2012 by BobJanova
I typically write explicit ToBytes/FromBytes* methods on classes I want to transfer. This is pretty fast, and allows you to choose exactly what state information needs to be transferred (any automated serialiser will take everything, and will have to use reflection to find the properties to...
11 Apr 2016 by mj01001
hiI wanted to ask few question about filesFor example mp3 fileWhen read as a binary array of bytesFor this I use algorithms to reduce the size of the byte array to a string or char would later become serious difficulties for his return or not?Because if I use the Hoffman algorithm(for...
11 Apr 2016 by OriginalGriff
That code doesn't compress anything!Partly because it writes the input data to the output stream instead of the byteOut data, and partly because even if it did, byteOut contains the same data as byteArray anyway...If you want to compress data in C#, then look at the GZipStream Class...
6 Feb 2012 by RDBurmon
Hello All ,I have one table called which has one binary(32) column.I need to convert the binary column data into human readable formatfor example One of row having below binary data0x0000000000000100000000000000000000000000000000000000000000000000The actual string is...
6 Feb 2012 by Corporal Agarn
Google is our friend.Have you tried CAST(bin AS VARCHAR(50)) where bin is your column. Note if this is encrypted you will not be able to do this.
29 May 2013 by kk2014
hi,how to convert datatype from varchar to binary(16) in db table in sql server 2005?thanks,kk
13 May 2013 by E.F. Nijboer
Needs to be done with an explicit cast. More info here:http://msdn.microsoft.com/en-us/library/aa226054%28v=sql.80%29.aspx[^]Good luck!
8 Apr 2015 by Varun Das
I need to pass a varchar field in a table to my windows form and change it on a button click to pdf file as output,my requirement is due to the extensive varchar size in the field so i need it to convert it into pdf
8 Apr 2015 by OriginalGriff
Try:using (SqlConnection con = new SqlConnection(strConnect)) { con.Open(); using (SqlCommand cmd = new SqlCommand("SELECT myPDFData FROM myTable", con)) { using (SqlDataReader reader = cmd.ExecuteReader()) { while (reader.Read()) ...