0

Looking at this question on Quora HERE ("Are data stored in registers and memory in hex or binary?"), I think the top answer is saying that data persistence is achieved through physical properties of hardware and is not directly relatable to either binary or hex.

I've always thought of computers as 'binary', but have just realized that that only applies to the usage of components (magnetic up/down or an on/off transistor) and not necessarily the organisation of, for example, memory contents.

i.e. you could, theoretically, create an abstraction in memory that used 'binary components' but that wasn't binary, like this:

100000110001010001100
100001001001010010010
111101111101010100001
100101000001010010010
100100111001010101100

And then recognize that as the (badly-drawn) image of 'hello', rather than the ASCII encoding of 'hello'.

An answer on SO (What's the difference between a word and byte?) mentions that processors can handle 'words', i.e. several bytes at a time, so while information representation has to be binary I don't see why information processing has to be.

Can computers do arithmetic on hex directly? In this case, would the internal representation of information in memory/registers be in binary or hex?

Zach Smith
  • 8,458
  • 13
  • 59
  • 133
  • Um, would you call an 8-bit register operation, say two's complement integer negation or arithmetic left shift, 256-ary or would you call that binary, too? – Tom Blodget Jul 19 '17 at 21:37
  • @TomBlodget I don't have a CS background, otherwise I guess this type of thing (low-level computer functionality) would have been covered in my college days. So I don't actually know what you mean... – Zach Smith Jul 20 '17 at 09:38
  • But yes. actually. the term '8-bit register operation answers my question. I was wondering if every operation was done at a single bit level – Zach Smith Jul 20 '17 at 11:43
  • No, some use 0 bits (depending on how you define operation) [Ex. [RET instruction](https://www.aldeid.com/wiki/X86-assembly/Instructions/ret)], some 1 [[JNE instruction](https://www.aldeid.com/wiki/X86-assembly/Instructions/jnz) uses a flag], most use a whole or part of a register or memory-fetched value [Ex. [ADD instruction](https://www.aldeid.com/wiki/X86-assembly/Instructions/add)] of whichever size addressed (typically a multiple of 8 bits). – Tom Blodget Jul 20 '17 at 11:52

1 Answers1

1

Perhaps "digital computer" would be a good starting term and then from there "binary digit" ("bit"). Electronically, the terms for the values are sometimes "high" and "low". You are right, everything after that depends on the operation. Most of the time, groups of bits are operated on together. Commonly groups are 1, 8, 16, 32 and 64 bits. The meaning of the bits depends on the program but some operations go hand-in-hand with some level of meaning.

When the meaning of a group of bits is not known or important, humans like to be able to decern the value of each bit. Binary could be used but more than 8 bits is hard to read. Although it is rare to operate on groups of 4 bits, hexadecimal is much more readable and is generally used regardless of the number of bits. Sometimes octal is used but that's based on contexts where there is some meaning to a subgrouping of the 3 bits or an avoidance of digits beyond 9.

Integers can be stored in two's complement format and often CPUs have instructions for such integers. Once such operation is negation. For a group of 8 bits, it would map 1 to -1,… 127 to -127, and -1 to 1, … -127 to 127, and 0 to 0 and -128 to -128. Decimal is likely the most valuable to humans here, not base 256, base 2 or base 16. In unsigned hexadecimal, that would be 01 to FF, …, 00 to 00, 80 to 80.

For an intro to how a CPU might do integer addition on a group of bits, see adder circuits.

Other number formats include IEEE-754 floating point and binary-coded decimal.

I think you understand that digital circuits are binary. So, based on the above, yes, operations do operate on a higher conceptual level despite the actual storage.

Tom Blodget
  • 20,260
  • 3
  • 39
  • 72
  • Thank you. that's a helpful link. Looking at this sentence: 'We're going to construct combinational logic circuits that perform binary addition' am I correct in assuming that every circuit is in itself binary? since electricity is either on or off (can only carry a binary digit)... but again, the circuit COULD, theoretically be designed to do hex addition, but then the individual steps would still be in binary. which would be confusing... – Zach Smith Jul 20 '17 at 11:52
  • The key CS concepts here are composition and iteration. Digital is binary for hardware simplicity. It is sometimes composed as binary-coded decimal for accuracy with non-integer numbers. There is no such motivation for hexadecimal. It's simply convenient way to display bits, particularly if grouped in 4s or 8s etc. – Tom Blodget Jul 20 '17 at 11:57