Results 1 to 8 of 8
  1. #1
    Join Date
    Jul 2009
    Posts
    6

    Unhappy Unanswered: MS SQL vs MY SQL PROBLEM

    Hello I need help ,

    I have this formula

    select ((m * power(2,7) + n) | 0x80000000) , where n,m are positive numbers,

    in any case the result is different in both servers ,

    for example if n=5,m=1 the result

    in MS SQL 2000 is -2147483007 (negative number ),

    but in My SQL 5 is 2147484289 (positive number ), but in my application I need negative number in result.

    How can I adjust this formula in order to get the same result like in SQL Server ?

    Can anyone help me to solve this issue ? Please help to solve this.

    Any help is appreciated.

    Thanks in advance.

  2. #2
    Join Date
    Apr 2008
    Location
    Iasi, Romania
    Posts
    561
    Provided Answers: 2
    Are you sure you are using the proper MySQL datatype?
    Florin Aparaschivei
    DB2 9.7, 10.5 on Windows
    Iasi, Romania

  3. #3
    Join Date
    Jul 2009
    Posts
    6

    Red face

    Quote Originally Posted by aflorin27
    Are you sure you are using the proper MySQL datatype?
    Yes , I'm wondering about the mathematical formula , which I can use instead of bitwise OR , because the main problem is this.

  4. #4
    Join Date
    Nov 2002
    Location
    Jersey
    Posts
    10,322
    yup, that's what I get

    Code:
    SELECT @@Version
    
    --Microsoft SQL Server 2005 - 9.00.3042.00 (Intel X86) 
    --	Feb  9 2007 22:47:07 
    --	Copyright (c) 1988-2005 Microsoft Corporation
    --	Standard Edition on Windows NT 5.2 (Build 3790: Service Pack 2)
    
    DECLARE @m int, @n int
    SELECT @m = 5, @n = 1
    
    SELECT ((@m * POWER(2,7) + @n) | 0x80000000) AS [Result]
    GO
    
    -- Returns 
    -- Result
    -- -----------
    -- -2147483007
    Anyone got mySQL set up?
    Brett
    8-)

    It's a Great Day for America everybody!

    dbforums Yak CorralRadio 'Rita
    dbForums Member List
    I'm Good Once as I ever was

    The physical order of data in a database has no meaning.

  5. #5
    Join Date
    Jul 2009
    Posts
    6
    Thanks Brett Kaiser,

    but in SQL SERVER I got the same result , the problem is that in MySQL I've got the positive number (see my first post)

  6. #6
    Join Date
    Apr 2008
    Location
    Iasi, Romania
    Posts
    561
    Provided Answers: 2
    According to MySQL documentation, the result of Bitwise OR is an unsigned 64-bit integer.
    Florin Aparaschivei
    DB2 9.7, 10.5 on Windows
    Iasi, Romania

  7. #7
    Join Date
    Jul 2009
    Posts
    6
    Quote Originally Posted by aflorin27
    According to MySQL documentation, the result of Bitwise OR is an unsigned 64-bit integer.
    I see! That's why it is positive

  8. #8
    Join Date
    Jul 2009
    Posts
    6
    Thanks aflorin27

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •