5 ms·
Bits to bytes means dividing by 8.
by jon_adler 4y ago
Bits to bytes means dividing by 8.
- tjoff 4y agoJust to add for clarity, b is used for bits and B for bytes. Though they are often mixed up. (... and a byte is not always 8 bits)
- mccorrinall 4y agoI believe the byte changed its meaning like many words did in the past. To a lot of younger developers a byte is synonymous with an octet.
- JadedBlueEyes 4y agoIn the CS tests for every UK exam board, a byte is always 8 bits
- jon_adler 4y agoA byte has been synonymous with an octet for as long as I can remember. I found a Wikipedia article [1] that describes the transition of a byte meaning the number of bits to encode character of text to an octet. [1] https://en.wikipedia.org/wiki/Units_of_information https://en.wikipedia.org/wiki/Units_of_information
- saagarjha 4y agoIn C it’s not when CHAR_BIT != 8.
- tjoff 4y agoIt does depend on context though. Transports often use 8b/10b, which is why SATA 6Gb/s is also 600 MB/s. https://en.wikipedia.org/wiki/8b/10b_encoding https://en.wikipedia.org/wiki/8b/10b_encoding A byte is also referred to the smallest addressable unit. Which in most cases is 8 bits but many (I guess mostly niche architectures) have much larger characters/bytes, and is still very much relevant.
- mccorrinall 4y agoI love your comments! Always learning something new. (this time about SATA)
- can16358p 4y agoI just had to google "is byte always 8 bits" so see that in historical context it wasn't always the case. But probably for all practical purposes in modern era, we can safely assume it's always 8 bits.
- huhtenberg 4y agoUnless you are a disk drive vendor, in which case you insist it's 10.
- can16358p 4y agoWhy? Assuming a byte being 10 bits instead of 8 bits would actually make the drive capacity lower in terms of bytes (of course not physically but for marketing), which a vendor probably doesn't want.
- rileymat2 4y agoI am not sure what the op is talking about with bytes, but it could be powers of 2 v. powers of ten for kb/mb/gb.
- sigio 4y agoYeah, that's the kibibytes vs kilobytes / gibibytes vs gigabytes diffence... Which adds up to ~7% difference in capacity when talking about GiB/GB, and even 12.5% when talking about PiB/PB Kibibyte (KiB) 1,024¹ = 1,024 Mebibyte (MiB) 1,024² = 1,048,576 Gibibyte (GiB) 1,024³ = 1,073,741,824 Tebibyte (TiB) 1,024⁴ = 1,099,511,627,776 Pebibyte (PiB) 1,024⁵ = 1,125,899,906,842,62
- doctor_eval 4y agoI'm old enough to remember parity bits and FEC, so I know that the number of bits per data byte might be 8, but the number of bits required to transmit a single byte might be more than 8, and the number of bytes needed to transmit a frame of data might also be higher than the number of bytes of payload within the frame. I know next to nothing about modern serial protocols, but nevertheless as a rule of thumb, and absent any other information, I tend to use 10 bits per byte when converting bits per second to bytes per second. Saves disappointment if nothing else.
- masklinn 4y agoYou're pretty much on the dot: what you're thinking of is 8b/10b encoding (https://en.wikipedia.org/wiki/8b/10b_encoding https://en.wikipedia.org/wiki/8b/10b_encoding) and it's exactly what USB uses historically. Recent standard revision (USB 3.1 Gen 2, as well as USB 3.2 Gen 2x2) switch to a more efficient 128b/132b encoding (https://en.wikipedia.org/wiki/64b/66b_encoding https://en.wikipedia.org/wiki/64b/66b_encoding), with ~3% encoding overhead rather than the historical 25.