Re: efficient two's complement of a byte array

Tech-Archive recommends: Speed Up your PC by fixing your registry



On Feb 17, 12:16 am, darthgha...@xxxxxxxxx wrote:
On Feb 16, 11:44 pm, "Bruce Wood" <brucew...@xxxxxxxxxx> wrote:



On Feb 16, 8:54 pm, darthgha...@xxxxxxxxx wrote:

So what you are all saying is that there is no easy way to get a two's
complement of a byte array? That sucks. I guess that's Microsoft's
gift to me?

I don't know if it's particularly _Microsoft's_ gift to you. More like
the modern Intel processor's gift to you. In fact, I don't think I've
ever worked on a language or a processor in which something as obscure
as taking the two's-complement of a byte array was optimized into some
special instruction or operation.

There's certainly an _easy_ way to do it: loop through the bytes and
take the two's complement of each one. That's pretty darned easy.

However, what you asked for was _faster_. As I said, I've never seen a
_fast_, short-cut way to do that, on any platform, on any chip.
Perhaps others with wider experience have, but not me.

Thanks for the response. That was the way I was hoping to avoid.
Looks like it's the best bet.
Thanks again for the time.
Chris

Looks like the newest version of Visual Studio will come with a
BigInteger class that I could use. It doesn't support bitwise right
now, but may be they will add it later.
Here's where I saw that:
http://blogs.msdn.com/bclteam/archive/2007/01/16/introducing-system-numeric-biginteger-inbar-gazit.aspx

.



Relevant Pages

  • Re: efficient twos complement of a byte array
    ... the modern Intel processor's gift to you. ... as taking the two's-complement of a byte array was optimized into some ... take the two's complement of each one. ... If you want twos-complement then it won't fly: ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: efficient twos complement of a byte array
    ... I don't know if it's particularly _Microsoft's_ gift to you. ... as taking the two's-complement of a byte array was optimized into some ... take the two's complement of each one. ... That's pretty darned easy. ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: efficient twos complement of a byte array
    ... I don't know if it's particularly _Microsoft's_ gift to you. ... as taking the two's-complement of a byte array was optimized into some ... take the two's complement of each one. ... That's pretty darned easy. ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: efficient twos complement of a byte array
    ... I don't know if it's particularly _Microsoft's_ gift to you. ... as taking the two's-complement of a byte array was optimized into some ... take the two's complement of each one. ... That's pretty darned easy. ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: subroutine stack and C machine model
    ... quid, and grabbed it as a gift for me. ... the size of an array argument...). ... I just checked that it is page 53 in the third edition. ...
    (comp.lang.c)