FixYa.com
Technical Support, Instructions & Repair Service


Tags:

Intel PRO/ 1000 MT 64BIT PCI- X QUAD PORT SERVER ADAPTER - BULK  Network Adapter

Bug in intel instruction set ?: NEG gives wrong...

By paulrmc - usenet poster


Hello,

neg -2147483648 becomes -2147483648 on my AMD X2 3800+ processor.

The integer range is: -2147483648 to 2147483647

Two's complement (negation?) is:

1. Invert all bits.

2. Add +1

Thus -2147483648 is represented as:

11111111111111111111111111111111

1. invert:

00000000000000000000000000000000

2. add +1:

00000000000000000000000000000001

However the outcome is:

11111111111111111111111111111111

Which is a wrong result ?!?

Ofcourse

00000000000000000000000000000001

Can be considered a wrong result as well... but at least it's a positive
wrap around.

Intel documents says nothing about this special case ?

Best would be to raise an exception ?

(Like divide by zero)

Bye,
Skybuck.

This Problem has been added to the Share Your Expertise Page under "My Work Queue".
Solution #1
posted on Aug 02, 2007
Not Rated (0)

pandamama

pandamama - usenet poster

Rank:Apprentice Apprentice
Rating: 0%, 0 votes
Here's some food for thought on this subject:

I'll use signed 8-bit, though this extends to any width (16, 32, 64, etc)
signed integers

NEG of 00000000 = 00000000
NEG of 11111111 = 00000001
NEG of 11111110 = 00000010

NEG of 10000010 = 01111110
NEG of 10000001 = 01111111
NEG of 10000000 = 10000000

Two values here have a NEG that is equal to itself.

For integer math, we know NEG of zero is always zero: -1 * 0 = 0

The other instance occurs when you're at the extreme negative value for the
width you are using. You can think of the computation in a few ways.
10000000 = -128 decimal. NEG of -128 dec = +128 dec, which would be
represented as 10000000 in binary. (The only reason we do not have a +128 in
signed 8-bit is because we have that defined as -128 already.)

Another way to look at it is this:

you have the following value ranges for signed 8-bit:

-127 decimal to -1 decimal
0
+1 decimal to +127 decimal
and a special overflow case: +/- 128

Never let your values reach this overflow case, and you'll be fine.
--
Bx.C / x87asm

...

Was this solution helpful? Show your Appreciation by rating it:

Solution #2
posted on Aug 02, 2007
Not Rated (0)

Powe33

Powe33 - usenet poster

Rank:Apprentice Apprentice
Rating: 0%, 0 votes
Playtime's over; it's well-known fact that the negative extreme's abs
is one larger than the positive extreme, so negating it wouldn't fit
anyway. It's a special case. Live with it.

Was this solution helpful? Show your Appreciation by rating it:

Solution #3
posted on Aug 02, 2007
Not Rated (0)

Bomber

Bomber - usenet poster

Rank:Apprentice Apprentice
Rating: 0%, 0 votes
If it makes you feel any better, you get an overflow flag, a sign flag, and
a carry flag on the operation.

--
Bx.C / x87asm

...

Was this solution helpful? Show your Appreciation by rating it:

Solution #4
posted on Aug 02, 2007
Not Rated (0)

Bouncy

Bouncy - usenet poster

Rank:Apprentice Apprentice
Rating: 0%, 0 votes
Indeed, made a little mistake ;)

The result remains negative though...

Weird result, I rather get an exception for it ;)

Bye,
Skybuck.

Was this solution helpful? Show your Appreciation by rating it:

Solution #5
posted on Aug 02, 2007
Not Rated (0)

Melissa

Melissa - usenet poster

Rank:Apprentice Apprentice
Rating: 0%, 0 votes
...

Correction:

-2147483648 is actually represented as:

10000000000000000000000000000000

for signed integer format.

Let's do that again.

1. invert:

01111111111111111111111111111111

2. add +1:

10000000000000000000000000000000

Hmmm a different result :)

And a very funny result as well.

When following the two's complement negation this case remains exactly the
same.

I still consider it an errornous result :) and an exception should be raised
;)

LOL.

Bye,
Skybuck.

Was this solution helpful? Show your Appreciation by rating it:

Solution #6
posted on Aug 02, 2007
Not Rated (0)

Ross

Ross - usenet poster

Rank:Apprentice Apprentice
Rating: 0%, 0 votes
You are not quite right ... (see below)

Right.

Nope. It is: 10000000000000000000000000000000

Nope. It is: 01111111111111111111111111111111

Nope. It is: 10000000000000000000000000000000

Nope. It is: 10000000000000000000000000000000

Nope. It is as right as you can get it ;-)

Was this solution helpful? Show your Appreciation by rating it:

Can you Help with these Network Adapters problems?

Network Adapters
D-Link DWA-130 running Vista
Can I install a D-Link DWA-130... Answer This...
Network Adapters
Using a Linksys wireless net...
Hi, I installed the drivers but... Answer This...
Network Adapters
help
I have reformat my laptop and... Answer This...
Network Adapters
what is what?
but i don't know what to... Answer This...
Network Adapters
network adapter driver
i have a smc network adapter... Answer This...
Repair Service
Find Network Adapter Repairman Near You:

FixYa does not evaluate or guarantee the accuracy of any information provided through its proposed solutions, posts, or Expert Assistance Sessions. By entering this site you declare you read and agreed to its Terms. You may NOT copy or distribute the content that appears on this site without written permission from FixYa Inc.
© 2005-2008, FixYa, Inc. or its affiliates
When the original poster rates a solution that was given to his own problem, that rating is locked!
X

Are you sure the solution content is Inappropriate?
   
Tech buddies can communicate directly to answer questions. Become a Tech Buddy and have direct access to your favorite expert for FREE!