binary

User permissions as bits in an integer

Let's say I'm storing an integer for each user in a database that represents their assigned permissions. The number stored is the sum of the powers of two associated with each permission assigned. What's the easiest way to check to see if a certain permission was granted (within VBScript/ASP, or generally)? The best idea I have is to c...

Why do I need special libraries (binaries) built for each Visual C++ version?

There are a lot of C++ libraries (most?) that come with special binaries built for each Visual C++ version (2003, 2005, 2008, 2010). What's the problem about linking a C++ library built for Visual C++ 2008 with Visual C++ 2010? ...

Why do we use Base64?

Wikipedia says Base64 encoding schemes are commonly used when there is a need to encode binary data that needs be stored and transferred over media that are designed to deal with textual data. This is to ensure that the data remains intact without modification during transport. But is it not that data is always stored/transmitted i...

Pitfalls of number values in Python, "How deep?"

I'm a fairly green programmer, and I'm learning Python right now. I'm up to chapter 17 in "Learn to Think Like a Computer Scientist" (Classes and Methods), and I just wrote my first doctest that failed in a way I truly do not fully understand: class Point(object): ''' represents a point object. attributes: x, y ''' ...

Serializing binary struct gcc vs cl

Full disclosure - this is homework, although completed and fully working, I'm searching for a nicer solution. I have a binary file, which was created by a program compiled within Visual Studio (I believe). The structure looks something like this. struct Record { char c; double d; time_t t; }; The size of this structure o...

Need help with binary plists.

I am writing a c# class that parses and writes binary plist files. All of the information I have gotten is from this Java implementation. http://www.koders.com/java/fidE214DE8B5C627C9E1C03ED93B488941BAE17AF01.aspx?s=base64#L111 I have successfully written the header and object table now I just need help understanding what the offset tab...

Binary parser or serialization ?

I want to store a graph of different objects for a game, their classes may or may not be related, they may or may not contain vectors of simple structures. I want parsing operation to be fast, data can be pretty big. Adding new things should not be hard, and it should not break backward compatibility. Smaller file size is kind of impor...

Output binary buffer with STL

I'm trying to use something that could best be described as a binary output queue. In short, one thread will fill a queue with binary data and another will pop this data from the queue, sending it to a client socket. What's the best way to do this with STL? I'm looking for something like std::queue but for many items at a time. Thanks ...

Storing a bunch of 3bits long binary data with PHP

Hi, My PHP program is working with an array of values ranging from 0 to 7. I'm trying to find the most effective way to store those values in PHP. By most effective I mean using the less number of bits. It's clear that each value only need 3 bits of storage space (b000=0 to b111=7). But what is the most efficient way to store those 3bi...

Converting bytes to a binary string in c#

In c# I am converting a byte to binary, the actual answer is 00111111 but the result being given is 111111. Now I really need to display even the 2 0s in front. Can anyone tell me how to do this? I am using: Convert.ToString(byteArray[20],2) and the byte value is 63 ...

What's the easiest way to get the binary representation of an integer?

Actually, I'm not asking how to implement this functionality myself. I know it wouldn't be very complicated. I just don't want to reinvent the wheel, so I was wondering if this functionality exists somewhere in the BCL. It seems like surely it's there somewhere... Example input/desired output: Input Output 1 1 2 ...

how do I convert fractional decimal numbers to fractional binary numbers using dc

So dc is a great tool for converting between bases - handy for those bit twiddling coding jobs. e.g to convert 1078 into binary I can do this: bash> echo "2o1078p" | dc 10000110110 However I can't get it to print fractions between 0 and 1 correctly. Trying to convert 0.3 into binary: bash> echo "2o10k 0.3p" | dc .0100 But 0.0100(bi...

Code Golf: JSON Binary Encoding/Decoding

The Challenge Encode ANY series of integers, floats, strings, nulls, booleans and arrays/objects of them, into a binary format and decode it again. The term object refers to a HashMap/Dictionary At the top level there's always a surrounding array or object, depending on the input The Test Input [-1, 0.1, 0, 'Foo', {'b': 8388608.25...

How can you force Mercurial (hg) to treat a file as binary?

I have a LaTeX hg repository for a paper and I use hg serve to display the progress to my coauthors. Until last week the file paper.pdf was treated as binary and its contents were not displayed in the changesets. (The users could download it via the raw link) Since last week, paper.pdf is treated as text and I see huge diffs of PDF code...

GCC C++ Linker section on FC13

I am trying to get OpenGL and Glut running on Eclipse Linux FC13. After spending two days on it, I admit that help is needed. On FC13 Eclipse, I see /usr/include/GL and /usr/include/SDL -- so the libs are there. I started Eclipse, and then tried to run a simple program on it, just like suggested here. However, two things were missing in...

Generate binary file with given structure

I have a device witch use binary format style config, and i have to generate that files on-the-fly. File structure must consist of a number of configuration settings (1 per parameter) each of the form: Type Length Value where: Type: is a single-octet identifier which defines the parameter Length: is a single octet containing the l...

Distributing a statically linked ELF 32bit Binary - Will it run on all platforms?

My team is ready to release the first version of our Linux program and would like to do so in the easiest possible manner (for users). The program needs no external files, no install, and is statically linked. ELF 32-bit LSB executable, Intel 80386, version 1 (GNU/Linux), statically linked, for GNU/Linux 2.6.15, not stripped My quest...

Consuming a WCF REST service from Android is very slow

I have a WCF REST service built with C# and it returns an image as part of a CPU intensive operation. The client is running on Android (Java) By default, it will return a text JSON object that looks something like this: {"d",[9,0,77,12,11,...]} Those are they bytes of the image. Fine. However, all the solutions for decoding this JSON...

Statically Linked ELF 32 bit Binary - Distro Specific

Hi All, I've already determined that statically linked programs can't always run between different distros. My question here, is if it is safe to distribute a statically linked program that is distro specific. For example, I'd have an Ubuntu version of the binary, and a Redhat version of the binary and the user just downloads the cor...

zip file encryption

I'm trying to block zip file open... How to block it.... Is there any other methods except modifying zip header info. My rosources are packed with zip file but I don't want to open it to users... Please let me know it ...