COPPER

A PS Audio Publication

Issue 40 • Free Online Magazine

Issue 40 QUIBBLES AND BITS

Two's a Compliment

[The article deals with two’s complement, but the title was spelled as it is as a bit of a joke by Richard. So—no emails to  Ye Olde Editor complaining of a typo are needed, thanks. —Ed.]

Most of us understand that PCM audio data “samples” (measures) the music signal many times a second (44,100 times a second for a CD) and stores the result in a number.  For CD audio this is a 16-bit number.  A 16-bit number can take on integer values anywhere between 0 and 65,535.  Integer values simply means whole-number values such as 19, 47,995 and 13,244.  But it cannot take on values such as 1.316 or 377½.  However, even if you’re fine with that, recall that the music waveforms we are trying to measure swing from positive to negative, rather from zero to a positive number.  So we need to be able to record -13,244 as well as +13,244.  Fear not, though – it turns out we can work around that.  An interesting property of binary numbers can be brought to bear.

A 16-bit number is just a string of 16 digits which can be either one or zero.  Here is an example, the number 13,244 expressed in ordinary 16-bit binary form: 0011001110111100.  [If I need to explain binary numbers to you, you’re reading the wrong article.]  If this were all zeros it would represent 0, and if it were all ones, it would represent 65,535.  But there are actually different ways in which to interpret a sequence of 16 binary digits, and one of these is called “Two’s Complement” (spelled with an “e”, not an “i”).

Let’s first talk about 15-bit numbers.  A 15-bit number can take on values between 0 and 32,767.  Wouldn’t it be nice if we could encode our music as one 15-bit number representing 0 to +32,767 for all those times when the musical waveform swings positive, and another 15-bit number representing 0 to -32,767 for all those times when the musical waveform swings negative?  In fact, we can do that very easily.  We would take a 16-bit number, and reserve one of the bits (say, the most significant bit) to read 0 to represent a positive number and 1 to represent a negative number, and use the remaining 15 bits to say how positive (or negative) it is.  Are you with me so far?

We need to make one small modification.  As described, both the positive and the negative swings encode the value zero.  We can’t allow two different numbers to represent the same value – it would make doing any math impossible – so we need to fix that.  We allow the negative waveform swings to encode the numbers -1 to -32,768, and the positive waveform swings to encode the numbers 0 to +32,767.  So now the value zero is unambiguously encoded as part of the positive waveform swing.  This gives us a system that can encode all of the integer values from -32,768 to +32,767 which makes us very happy.

What I have described, in a roundabout way, is conceptually similar to what we actually end up doing.  The actual solution is referred to mathematically as the “Two’s Complement” of our 16-bit number, and shares a lot with my simplified description.  Two’s complement lets us express 16-bit data in a form that covers both positive and negative values, which makes us very happy.  It differs from my more simple description by taking all the negative numbers and turning their zeros into ones, and their ones into zeros.  This is done for mathematical reasons that I won’t go into here.

It turns out that two’s complement also makes computers very happy, because numbers represented as two’s complement respond identically and correctly to the integer arithmetic operations of addition, subtraction, and multiplication.  So we can manipulate them in exactly the same way as we do regular integers.  In fact, two’s complement representation is so inherently useful to computers that software engineers have devised a much more user-friendly term for them – Signed Integers.

Two’s Complement (or Signed Integer) representation is such a huge convenience that virtually all audio processing uses this representation.  For example, simple signal processing functions like Digital Volume Control are more efficient to code with Signed Integers.

There is one thing to bear in mind, though, and it catches some people out.  Recall that the negative swing encodes a higher maximum number than the positive swing.  Here I am going to shift the discussion from the illustrative example of 16-bit numbers to the more general case of N-bit numbers.  The largest negative swing that can be encoded is 2^(N-1) whereas the largest positive swing that can be encoded is 2^(N-1) – 1.  Where this becomes important is to note that the ratio between the two is not constant, and varies with N, the bit depth.  This comes into play if you are designing a D-to-A Converter with separate DACs for the negative and positive voltage swings.  You need to design it such that the negative and positive sides both reach the same peak output with an input value of 2^(N-1), while recognizing that the positive side can never see it in practice, since it can only ever receive a maximum input value of 2^(N-1) – 1.  There is at least one high-end DAC that I know of which does this intentionally wrongly, and makes a wrong-headed claim that they are uniquely solving a known problem.

Similar considerations exist when normalizing the output of a DSP stage (which should properly be in floating point format) for rendering to integer format.  The processed floating point data is typically normalized to ±1.0000 and it would be an error to map this to ±2^(N-1) in Two’s Complement integer space, because this would result in clipping (or worse) of the positive voltage swing at its peak.  Instead it must be mapped to ±2^(N-1) – 1.

Such things make a difference when you operate at the cutting edge of sound quality.

More from Issue 40

View All Articles in Issue 40

Search Copper Magazine

#231 Piano Prodigy Jude Kofie Releases His Debut Album On Octave Records by Frank Doris Jun 01, 2026 #231 Underappreciated Artists, Part Two: City Boy by Rich Isaacs Jun 01, 2026 #231 Music and the Art of Creation: Talking With Saxophonist Rob Scheps by Joe Caplan Jun 01, 2026 #231 How to Play in a Rock Band, 24: Further Adventures at the 2026 Montauk Music Festival by Frank Doris Jun 01, 2026 #231 Courtney Barnett: Creature of Habit by Wayne Robins Jun 01, 2026 #231 Angine de Poitrine: Interstellar Guitar Rock Saviors Headed for Late-Night TV Pop Stardom? by Mark Lepage Jun 01, 2026 #231 My Impressions of AXPONA 2026, Part One by Frank Doris Jun 01, 2026 #231 2026 La Jolla Concours d'Elegance: Another Aesthetic Feast by B. Jan Montana Jun 01, 2026 #231 Country Music Icon Jo Dee Messina’s Bridges: A New Beginning by Ray Chelstowski Jun 01, 2026 #231 The Luxury Dispatch Hosts a Video Podcast With Ken Kessler by Ken Kessler Jun 01, 2026 #231 The Vinyl Beat: Tracking in the Motor City by Rudy Radelic Jun 01, 2026 #231 Lots of Fun With DSP: The Ferrum Audio WANDLA DAC and Its Tube Mode by Frank Doris Jun 01, 2026 #231 From The Audiophile's Guide: Digital Source Components and Streaming Audio by Paul McGowan Jun 01, 2026 #231 Onkyo’s Monster M-510 power amplifier by The Staff at Just Audio Jun 01, 2026 #231 PS Audio in the News by PS Audio Staff Jun 01, 2026 #231 Naming Convention by Peter Xeni Jun 01, 2026 #231 Les Invisibles by Frank Doris Jun 01, 2026 #231 Wildlife Scene by James Schrimpf Jun 01, 2026 #230 Camaraderie by B. Jan Montana May 04, 2026 #230 AXPONA 2026: A Family Gathering by Paul McGowan May 04, 2026 #230 Pianist Ryan Benthall Explores Jazz Realms and Far Beyond With Divine Sky by Frank Doris May 04, 2026 #230 The Vinyl Beat in AXPONA-Land by Rudy Radelic May 04, 2026 #230 Teddy Thompson’s Musical Growth Deepens With Never Be the Same by Ray Chelstowski May 04, 2026 #230 More Fun in the Sun: Florida Audio Expo, Part Two by Frank Doris May 04, 2026 #230 CanJam NYC 2026 Show Report: Heady Sound, Part Two by Frank Doris and Harris Fogel May 04, 2026 #230 Sonic Youth On Murray Street by Wayne Robins May 04, 2026 #230 Graffeo Coffee: A Symphony of Sensory Experience by Joe Caplan May 04, 2026 #230 The Saul Authority: The Story of Hi-Fi Pioneer Saul Marantz by Olivier Meunier-Plante May 04, 2026 #230 How to Play in a Rock Band, 23: Encounters With Famous Musicians, Part Two by Frank Doris May 04, 2026 #230 An Outlier in the Rack: A Vintage BIC Beam Box by The Staff at Just Audio May 04, 2026 #230 PS Audio in the News by PS Audio Staff May 04, 2026 #230 A Cautionary Tale by Rich Isaacs May 04, 2026 #230 Reel-to-Reel Roots, Part 33 (Revised): Ken Kessler Reports On the 2026 (British) AudioJumble by Ken Kessler May 04, 2026 #230 Text Messaging by Frank Doris May 04, 2026 #230 The Audiophile Rat Race by Peter Xeni May 04, 2026 #230 On the Rocks by Rich Isaacs May 04, 2026 #229 The Earliest Stars of Country Music, Part Three by Jeff Weiner Apr 06, 2026 #229 The Healing Power of Music and Sound at the Omega Institute by Joe Caplan Apr 06, 2026 #229 CanJam NYC 2026 Show Report: Heady Sound, Part One by Frank Doris Apr 06, 2026 #229 Florida Audio Expo 2026: Warming Up to High-End Audio, Part One by Frank Doris Apr 06, 2026 #229 Quick Takes: Anne Bisson, Sam Morrison, The Velvet Underground, and the Stooges by Frank Doris Apr 06, 2026 #229 The Vinyl Beat: New Arrivals, and Old Audio Show Demo Scores to Settle by Rudy Radelic Apr 06, 2026 #229 Harvard Gets a High-End Audio Education by Frank Doris Apr 06, 2026 #229 No Country for Old Knees by B. Jan Montana Apr 06, 2026 #229 How To Play in A Rock Band, 22: Encounters With Famous Musicians, Part 1 by Frank Doris Apr 06, 2026 #229 The Soulful Grooves of Guinea-Bissau by Steve Kindig Apr 06, 2026 #229 Four-Hand Piano Performance at Its Finest by Stephan Haberthür Apr 06, 2026

Two's a Compliment

[The article deals with two’s complement, but the title was spelled as it is as a bit of a joke by Richard. So—no emails to  Ye Olde Editor complaining of a typo are needed, thanks. —Ed.]

Most of us understand that PCM audio data “samples” (measures) the music signal many times a second (44,100 times a second for a CD) and stores the result in a number.  For CD audio this is a 16-bit number.  A 16-bit number can take on integer values anywhere between 0 and 65,535.  Integer values simply means whole-number values such as 19, 47,995 and 13,244.  But it cannot take on values such as 1.316 or 377½.  However, even if you’re fine with that, recall that the music waveforms we are trying to measure swing from positive to negative, rather from zero to a positive number.  So we need to be able to record -13,244 as well as +13,244.  Fear not, though – it turns out we can work around that.  An interesting property of binary numbers can be brought to bear.

A 16-bit number is just a string of 16 digits which can be either one or zero.  Here is an example, the number 13,244 expressed in ordinary 16-bit binary form: 0011001110111100.  [If I need to explain binary numbers to you, you’re reading the wrong article.]  If this were all zeros it would represent 0, and if it were all ones, it would represent 65,535.  But there are actually different ways in which to interpret a sequence of 16 binary digits, and one of these is called “Two’s Complement” (spelled with an “e”, not an “i”).

Let’s first talk about 15-bit numbers.  A 15-bit number can take on values between 0 and 32,767.  Wouldn’t it be nice if we could encode our music as one 15-bit number representing 0 to +32,767 for all those times when the musical waveform swings positive, and another 15-bit number representing 0 to -32,767 for all those times when the musical waveform swings negative?  In fact, we can do that very easily.  We would take a 16-bit number, and reserve one of the bits (say, the most significant bit) to read 0 to represent a positive number and 1 to represent a negative number, and use the remaining 15 bits to say how positive (or negative) it is.  Are you with me so far?

We need to make one small modification.  As described, both the positive and the negative swings encode the value zero.  We can’t allow two different numbers to represent the same value – it would make doing any math impossible – so we need to fix that.  We allow the negative waveform swings to encode the numbers -1 to -32,768, and the positive waveform swings to encode the numbers 0 to +32,767.  So now the value zero is unambiguously encoded as part of the positive waveform swing.  This gives us a system that can encode all of the integer values from -32,768 to +32,767 which makes us very happy.

What I have described, in a roundabout way, is conceptually similar to what we actually end up doing.  The actual solution is referred to mathematically as the “Two’s Complement” of our 16-bit number, and shares a lot with my simplified description.  Two’s complement lets us express 16-bit data in a form that covers both positive and negative values, which makes us very happy.  It differs from my more simple description by taking all the negative numbers and turning their zeros into ones, and their ones into zeros.  This is done for mathematical reasons that I won’t go into here.

It turns out that two’s complement also makes computers very happy, because numbers represented as two’s complement respond identically and correctly to the integer arithmetic operations of addition, subtraction, and multiplication.  So we can manipulate them in exactly the same way as we do regular integers.  In fact, two’s complement representation is so inherently useful to computers that software engineers have devised a much more user-friendly term for them – Signed Integers.

Two’s Complement (or Signed Integer) representation is such a huge convenience that virtually all audio processing uses this representation.  For example, simple signal processing functions like Digital Volume Control are more efficient to code with Signed Integers.

There is one thing to bear in mind, though, and it catches some people out.  Recall that the negative swing encodes a higher maximum number than the positive swing.  Here I am going to shift the discussion from the illustrative example of 16-bit numbers to the more general case of N-bit numbers.  The largest negative swing that can be encoded is 2^(N-1) whereas the largest positive swing that can be encoded is 2^(N-1) – 1.  Where this becomes important is to note that the ratio between the two is not constant, and varies with N, the bit depth.  This comes into play if you are designing a D-to-A Converter with separate DACs for the negative and positive voltage swings.  You need to design it such that the negative and positive sides both reach the same peak output with an input value of 2^(N-1), while recognizing that the positive side can never see it in practice, since it can only ever receive a maximum input value of 2^(N-1) – 1.  There is at least one high-end DAC that I know of which does this intentionally wrongly, and makes a wrong-headed claim that they are uniquely solving a known problem.

Similar considerations exist when normalizing the output of a DSP stage (which should properly be in floating point format) for rendering to integer format.  The processed floating point data is typically normalized to ±1.0000 and it would be an error to map this to ±2^(N-1) in Two’s Complement integer space, because this would result in clipping (or worse) of the positive voltage swing at its peak.  Instead it must be mapped to ±2^(N-1) – 1.

Such things make a difference when you operate at the cutting edge of sound quality.

0 comments

Leave a comment

0 Comments

Your avatar

Loading comments...

🗑️ Delete Comment

Enter moderator password to delete this comment:

✏️ Edit Comment

Enter your email to verify ownership: