## Is it possible to program in binary?

Of course. It’s more commonly called machine code. It’s basically assembly language without the mnemonic devices. Someone who knows assembly very well could program in machine code with additional effort, referring to opcode listings (e.g. x86) as needed. Would I do it? No. Even assembly is only useful in rare circumstances, and there’s no reason (beside demonstrating your skills) … Read more

## Converting an integer to binary in C

If you want to transform a number into another number (not number to string of characters), and you can do with a small range (0 to 1023 for implementations with 32-bit integers), you don’t need to add char* to the solution HalosGhost suggested to compact the code into a single line

## convert decimal numbers to excess-127 representations

Assuming you are referring to Offset binary: https://en.wikipedia.org/wiki/Offset_binary, of which the most famous example would be Excess-3: https://en.wikipedia.org/wiki/Excess-3, then the solution would be: a) 77 + 127 mod 256 = 204 mod 256 = 204 = 11001100 b) -42 + 127 mod 256 = 85 mod 256 = 85 = 01010101 etc…

## What is the “biggest” negative number on a 4-bit machine?

That would be -8 to +7

## How to used the alphabet binary symbols

You would only need 5 bits because you are counting to 26 (if we take only upper or lowercase letters). 5 bits will count up to 31, so you’ve actually got more space than you need. You can’t use 4 because that only counts to 15. If you want both upper and lowercase then 6 … Read more

## Are the shift operators (<<, >>) arithmetic or logical in C?

According to K&R 2nd edition the results are implementation-dependent for right shifts of signed values. Wikipedia says that C/C++ ‘usually’ implements an arithmetic shift on signed values. Basically you need to either test your compiler or not rely on it. My VS2008 help for the current MS C++ compiler says that their compiler does an arithmetic shift.

## How is overflow detected in two’s complement?

I see that when I subtract positive and negative number using two’s complement I get overflows. For example, if I subtract 1 from 2 I get: So here the result has fifth left bit 10001 – is it overflow? I’ve found these rules for detected overflows with two’s complement: If the sum of two positive numbers yields a negative … Read more

## binary bomb lab phase 6

What I know about this code is : 1. Input should be six numbers, and they should be different. 2. The range of numbers is 1 to 6. And the node is : So, the value of node1 to node6 are f6, 304, b7, eb, 21f, 150. I know b7 < eb < f6 < … Read more

## What is the difference between signed and unsigned binary

The “signed” indicator means that the item can hold positive or negative values. “Unsigned” doesn’t distinguish between positive and negative values. A signed/unsigned variable can refer to any numerical data type (such as binary, integer, float, etc). Each data type might be further defined as signed or unsigned. For example, an 8-bit signed binary could … Read more

## Reading a binary file with python

Read the binary file content like this: then “unpack” binary data using struct.unpack: The start bytes: struct.unpack(“iiiii”, fileContent[:20]) The body: ignore the heading bytes and the trailing byte (= 24); The remaining part forms the body, to know the number of bytes in the body do an integer division by 4; The obtained quotient is multiplied by … Read more