←back to thread

182 points Twirrim | 5 comments | | HN request time: 0.773s | source
Show context
WalterBright ◴[] No.41875254[source]
D made a great leap forward with the following:

1. bytes are 8 bits

2. shorts are 16 bits

3. ints are 32 bits

4. longs are 64 bits

5. arithmetic is 2's complement

6. IEEE floating point

and a big chunk of wasted time trying to abstract these away and getting it wrong anyway was saved. Millions of people cried out in relief!

Oh, and Unicode was the character set. Not EBCDIC, RADIX-50, etc.

replies(3): >>41875486 #>>41875539 #>>41875878 #
gerdesj ◴[] No.41875486[source]
"1. bytes are 8 bits"

How big is a bit?

replies(6): >>41875621 #>>41875701 #>>41875768 #>>41876060 #>>41876149 #>>41876238 #
1. poincaredisk ◴[] No.41875621[source]
A bit is either a 0 or 1. A byte is the smallest addressable piece of memory in your architecture.
replies(2): >>41875706 #>>41875737 #
2. elromulous ◴[] No.41875706[source]
Technically the smallest addressable piece of memory is a word.
replies(2): >>41876026 #>>41876056 #
3. Nevermark ◴[] No.41875737[source]
Which … if your heap always returns N bit aligned values, for some N … is there a name for that? The smallest heap addressable segment?
4. asveikau ◴[] No.41876026[source]
Depends on your definition of addressable.

Lots of CISC architectures allow memory accesses in various units even if they call general-purpose-register-sized quantities "word".

Iirc the C standard specifies that all memory can be accessed via char*.

5. Maxatar ◴[] No.41876056[source]
I don't think the term word has any consistent meaning. Certainly x86 doesn't use the term word to mean smallest addressable unit of memory. The x86 documentation defines a word as 16 bits, but x86 is byte addressable.

ARM is similar, ARM processors define a word as 32-bits, even on 64-bit ARM processors, but they are also byte addressable.

As best as I can tell, it seems like a word is whatever the size of the arithmetic or general purpose register is at the time that the processor was introduced, and even if later a new processor is introduced with larger registers, for backwards compatibility the size of a word remains the same.