Skip to main content
29 events
when toggle format what by license comment
Oct 9 at 19:42 comment added supercat @JohnR.Strohm: With two's-complement, shifting values in the range -12 to -9 to the right two places, to divide by 4, will yield -3. Adding one or two to any number first will yield a rounded result (adding one will round the midpoint toward negative infinity; adding two will round toward positive infinity). With one's-complement, shifting by 2 to divide numbers -15 to -12 will yield -3; yielding rounded result would require adding 1 or 2 to positive numbers and subtracting 1 or 2 from negative ones.
Jul 29, 2022 at 12:10 comment added John R. Strohm It is worth mentioning that one's complement has a very nice property for certain digital signal processing algorithms. It inherently truncates toward zero. Two's complement truncates toward negative infinity. This can cause certain simple filters to diverge without limit. The fix is, essentially, emulating one's complement and forcing truncation toward zero if the result was negative. This is NOT good for real-time image processing, as it can significantly increase the per-pixel instruction counts, which are what eat your timeline alive, without salt.
Mar 26, 2021 at 12:45 history edited user3840170 CC BY-SA 4.0
added 8 characters in body
May 22, 2020 at 9:59 comment added Max Barraclough "it specifies that a signed integer may hold values -32767 to +32767" The standard says that INT_MIN must be at least that low, but it may be lower, and typically is. Seems to me the C standard was written with two's complement in mind, but was designed to permit other representations too. In particular, the way signed->unsigned conversions are defined, seems to favour two's complement. Iff two's complement is used, the bit-pattern is unchanged. stackoverflow.com/a/832772
Feb 29, 2020 at 18:49 comment added supercat @Jules: Ones' complement floating-point makes sense if one views the sign bit as extending infinitely far in both directions. Just as subtracting 1 from ...00000 would yield ...11111, subtracting an infinitesimal amount from ...000.000... would yield ...111.111...; interestingly, bitwise operators would behave sensibly with such a format, with the caveat that truncation may be necessary when ANDing two values with opposite sign or ORing two values with the same sign.
Feb 27, 2020 at 17:12 comment added supercat @PatrickSchlüter: It was also written with the expectations that people working with various platforms and application fields would recognize and respect precedents appropriate to those fields when practical, and would be more familiar than the Committee with such precedents. The only time anyone should care about whether the Standard mandates something that would be practical on all known platforms should be if someone has to write a C compiler for a platform where it would be impractical.
Feb 27, 2020 at 8:27 comment added Patrick Schlüter The C standard is written with the intent to not exclude unnecessarily possible representations. So it will make its definition as close as possible to the least common denominator of all platform. This has absolutely no bearing on the importance of the platform.
Feb 27, 2020 at 5:19 answer added Mathieu Bouchard timeline score: 4
Jan 28, 2019 at 11:04 answer added JeremyP timeline score: 2
S Jan 26, 2019 at 19:21 history suggested user39
real tag instead of untagged
Jan 26, 2019 at 17:46 review Suggested edits
S Jan 26, 2019 at 19:21
Jul 27, 2018 at 10:06 vote accept Omar and Lorraine
Jul 26, 2018 at 16:12 answer added lvd timeline score: 6
Jul 26, 2018 at 10:33 history edited Stephen Kitt CC BY-SA 4.0
Plural (it’s significant).
Jul 26, 2018 at 0:54 comment added Erik Eidt The early days of computing were heavily driven by hardware limitations. Anything that made the hardware simpler was good. This pattern kept repeating: when IC's were developed, more advanced hardware offerings took a big step backward in other complexity, going from 18- or 36- bit CPUs to 8-bit processors (though now single chip).
Jul 26, 2018 at 0:47 comment added Digital Trauma Internally its rare, but don't forget IP, TCP and UDP checksums are all calculated with one's complement.
Jul 25, 2018 at 23:53 comment added Jules @Ray - one's complement floating point is perfectly sensible, and was used in the CDC6600 and (I believe) 7600, which were for many, many years considered the best computers available for numeric computations.
Jul 25, 2018 at 23:24 comment added dgnuff "The C standard is obviously written with one's complement machine in mind; for example, it specifies that a signed integer may hold values -32767 to +32767." In some respects, yes it was written with 1s complement in mind. However, not specifically. In particular, the C standard was written to be as implementation agnostic as possible. The above range allows for 2s complement, 1s complement and sign/magnitude.
Jul 25, 2018 at 22:43 answer added supercat timeline score: 21
Jul 25, 2018 at 22:39 comment added Stephen Kitt @Ray all I wrote was “IEEE 754 uses sign/magnitude”. I wasn’t suggesting anything about whether ones’ or two’s complements would be appropriate.
Jul 25, 2018 at 22:02 comment added Ray @StephenKitt 754 deals exclusively with floating point. One's complement and two's complement don't really make sense for non-integer types.
Jul 25, 2018 at 20:53 comment added Tommy Because all too often one's complement turns into one's evil twin?
Jul 25, 2018 at 20:28 comment added cup The fact that you can have a positive or negative zero would lead to no end of confusion. I remember doing this as a student - I had to write out the bit pattern before I figured it out.
Jul 25, 2018 at 18:08 comment added Stephen Kitt @Toby the IBM 700/7000 series used sign/magnitude. And IEEE 754 uses sign/magnitude.
Jul 25, 2018 at 17:17 comment added Toby Speight The C Standard definition also permits sign/magnitude representation; I don't know which (if any) popular systems use(d) that.
Jul 25, 2018 at 15:23 history edited Leo B. CC BY-SA 4.0
factual
Jul 25, 2018 at 13:02 answer added Raffzahn timeline score: 17
Jul 25, 2018 at 13:01 answer added Stephen Kitt timeline score: 46
Jul 25, 2018 at 12:43 history asked Omar and Lorraine CC BY-SA 4.0