Isn't there a typo somewhere... 
Shouldn't you expect 5 instead of -5 (15 - id where id = 10)??   

Nevermind, let's assume that there is a typo somewhere and the correct expected value 
is -5... however, in the domain of unsigned arithmetics -5 is precisely 
18446744073709551611... don't you believe me:  look at this:

18446744073709551611 + 5 = 18446744073709551616 which is 2 to power 64 (2^64). Clearly 
in the architecture that you are using an unsigned int is a 64 bits integer... if you 
set all the bits to 1 you will get the largest unsigned int in your system and that is 
18446744073709551615 which is (2^64)-1.  if you increment it by one... all the bits 
switch to 0.  Hence within your architecture 2^64 = 0 and -5 is represented correctly 
by 18446744073709551611 (which is 2^64 - 5).

Nasser
sql, smallint, ...

---------- Brian Lindner <[EMAIL PROTECTED]> writes:

Return-Path: <[EMAIL PROTECTED]>
Received: from mx11.lax.untd.com (mx11.lax.untd.com [10.130.24.71])
        by maildeliver03.nyc.untd.com with SMTP id AAA9CYGS4AWCVYC2
        for <[EMAIL PROTECTED]> (sender 
<[EMAIL PROTECTED]>);
        Sun, 19 Jan 2003 16:35:22 -0500 (EST)
Received: from web.mysql.com (web.mysql.com [213.136.49.183])
        by mx11.lax.untd.com with SMTP id AAA9CYGS3A42HYBJ
        for <[EMAIL PROTECTED]> (sender 
<[EMAIL PROTECTED]>);
        Sun, 19 Jan 2003 13:35:21 -0800 (PST)
Received: (qmail 2737 invoked by uid 7797); 19 Jan 2003 21:29:14 -0000
Mailing-List: contact [EMAIL PROTECTED]; run by ezmlm (http://www.ezmlm.org)
List-ID: <mysql.mysql.com>
Precedence: bulk
List-Help: <mailto:[EMAIL PROTECTED]>
List-Unsubscribe: <mailto:[EMAIL PROTECTED]>
List-Post: <mailto:[EMAIL PROTECTED]>
List-Subscribe: <mailto:[EMAIL PROTECTED]>
Delivered-To: mailing list [EMAIL PROTECTED]
Received: (qmail 2704 invoked from network); 19 Jan 2003 21:29:13 -0000
Date: Sun, 19 Jan 2003 16:28:43 -0500
From: Brian Lindner <[EMAIL PROTECTED]>
X-Mailer: The Bat! (v1.62 Christmas Edition) UNREG / CD5BF9353B3B7091
Reply-To: Brian Lindner <[EMAIL PROTECTED]>
X-Priority: 3 (Normal)
Message-ID: <[EMAIL PROTECTED]>
To: "Octavian Rasnita" <[EMAIL PROTECTED]>
CC: "MySQL" <[EMAIL PROTECTED]>
Subject: Re: Substraction
In-Reply-To: <001901c2bfe4$58e8dda0$[EMAIL PROTECTED]>
References: <001901c2bfe4$58e8dda0$[EMAIL PROTECTED]>
MIME-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit

Octavian,

Sunday, January 19, 2003, 7:31:57 AM, you wrote:
> Hi all,

> I've tried the following query:

> create table test(id int unsigned);
> insert into test values(10);
> select 15 - id from test;

> The result is 18446744073709551611 instead of -5.

I ran this.. and it worked for me

MySql 4.0.7 on Linux... ran it through phpMyAdmin

> Am I doing something wrong?

> Thank you.

> Teddy,
> Teddy's Center: http://teddy.fcc.ro/
> Email: [EMAIL PROTECTED]



> ---------------------------------------------------------------------
> Before posting, please check:
>    http://www.mysql.com/manual.php   (the manual)
>    http://lists.mysql.com/           (the list archive)

> To request this thread, e-mail <[EMAIL PROTECTED]>
> To unsubscribe, e-mail <[EMAIL PROTECTED]>
> Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php





--
 Brian
 Email: <[EMAIL PROTECTED]>




---------------------------------------------------------------------
Before posting, please check:
   http://www.mysql.com/manual.php   (the manual)
   http://lists.mysql.com/           (the list archive)

To request this thread, e-mail <[EMAIL PROTECTED]>
To unsubscribe, e-mail <[EMAIL PROTECTED]>
Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php






---------------------------------------------------------------------
Before posting, please check:
   http://www.mysql.com/manual.php   (the manual)
   http://lists.mysql.com/           (the list archive)

To request this thread, e-mail <[EMAIL PROTECTED]>
To unsubscribe, e-mail <[EMAIL PROTECTED]>
Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php

Reply via email to