Sybase NNTP forums - End Of Life (EOL)

The NNTP forums from Sybase - forums.sybase.com - are now closed.

All new questions should be directed to the appropriate forum at the SAP Community Network (SCN).

Individual products have links to the respective forums on SCN, or you can go to SCN and search for your product in the search box (upper right corner) to find your specific developer center.

Stange behaviour when deviding by SQRT()

3 posts in General Discussion Last posting was on 2006-06-26 21:48:57.0Z
Stelios Stylianou Posted on 2006-06-22 07:30:04.0Z
From: "Stelios Stylianou" <piosarota@piosarota.com.cy>
Newsgroups: ianywhere.public.general
Subject: Stange behaviour when deviding by SQRT()
Lines: 23
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 6.00.2900.2180
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.2180
X-RFC2646: Format=Flowed; Original
X-Original-NNTP-Posting-Host: adslon-150-15.logos.cy.net
Message-ID: <449a45f0@forums-2-dub>
X-Original-Trace: 22 Jun 2006 00:25:36 -0700, adslon-150-15.logos.cy.net
X-Original-NNTP-Posting-Host: forums-2-dub.sybase.com
X-Original-Trace: 22 Jun 2006 00:25:37 -0800, forums-2-dub.sybase.com
NNTP-Posting-Host: forums-master.sybase.com
X-Original-NNTP-Posting-Host: forums-master.sybase.com
Date: 22 Jun 2006 00:30:04 -0700
X-Trace: forums-1-dub 1150961404 10.22.108.75 (22 Jun 2006 00:30:04 -0700)
X-Original-Trace: 22 Jun 2006 00:30:04 -0700, forums-master.sybase.com
X-Authenticated-User: ngsysop
Path: forums-1-dub!not-for-mail
Xref: forums-1-dub ianywhere.public.general:5453
Article PK: 1498

Hi all,

I'm using ASA902 build 3221 under WINXP

I execute the following SQL statement in dbisqlg.exe

SELECT SQRT(9),
(4800.18 / SQRT(9)) as col1,
(4800.18 / ROUND(SQRT(9), 0)) as clo2,
(4800.18 / 3) as clo3;

The results are:
SQRT(9) col1 clo2
clo3
3.0 1600.0600000000002 1600.0600000000002 1600.0600

Any reason this is correct?
Does anyone face similar behaviour?

Thanks
Stelios


Breck Carter [Team iAnywhere] Posted on 2006-06-22 11:07:43.0Z
From: "Breck Carter [Team iAnywhere]" <NOSPAM__bcarter@risingroad.com>
Newsgroups: ianywhere.public.general
Subject: Re: Stange behaviour when deviding by SQRT()
Organization: RisingRoad Professional Services
Reply-To: NOSPAM__bcarter@risingroad.com
Message-ID: <f2uk92po7rhqj16ana6k9194miljn9bioc@4ax.com>
References: <449a45f0@forums-2-dub>
X-Newsreader: Forte Agent 2.0/32.640
MIME-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit
X-Original-NNTP-Posting-Host: host06.hourh.hyatthsiagx.com
X-Original-Trace: 22 Jun 2006 04:03:03 -0700, host06.hourh.hyatthsiagx.com
Lines: 51
X-Original-NNTP-Posting-Host: forums-2-dub.sybase.com
X-Original-Trace: 22 Jun 2006 04:03:06 -0800, forums-2-dub.sybase.com
NNTP-Posting-Host: forums-master.sybase.com
X-Original-NNTP-Posting-Host: forums-master.sybase.com
Date: 22 Jun 2006 04:07:43 -0700
X-Trace: forums-1-dub 1150974463 10.22.108.75 (22 Jun 2006 04:07:43 -0700)
X-Original-Trace: 22 Jun 2006 04:07:43 -0700, forums-master.sybase.com
X-Authenticated-User: ngsysop
Path: forums-1-dub!not-for-mail
Xref: forums-1-dub ianywhere.public.general:5457
Article PK: 1502

The rules for data type conversion in SQL Anywhere arithmetic
expressions are (a) complex and (b) undocumented.

In any particular case, however, you can use EXPRTYPE to discover what
is actually being done.

SELECT EXPRTYPE ( 'SELECT 9', 1 ),
EXPRTYPE ( 'SELECT SQRT(9)', 1 ),
EXPRTYPE ( 'SELECT 4800.18', 1 ),
EXPRTYPE ( 'SELECT 4800.18 / SQRT(9)', 1 ),
EXPRTYPE ( 'SELECT ROUND(SQRT(9), 0)', 1 ),
EXPRTYPE ( 'SELECT 4800.18 / ROUND(SQRT(9), 0)', 1 ),
EXPRTYPE ( 'SELECT 4800.18 / 3', 1 );

I suggest you decide what data types you want to use, then call CAST
to enforce your decisions.

Breck

On 22 Jun 2006 00:30:04 -0700, "Stelios Stylianou"

<piosarota@piosarota.com.cy> wrote:

>Hi all,
>
>I'm using ASA902 build 3221 under WINXP
>
>I execute the following SQL statement in dbisqlg.exe
>
>SELECT SQRT(9),
> (4800.18 / SQRT(9)) as col1,
> (4800.18 / ROUND(SQRT(9), 0)) as clo2,
> (4800.18 / 3) as clo3;
>
>The results are:
>SQRT(9) col1 clo2
>clo3
>3.0 1600.0600000000002 1600.0600000000002 1600.0600
>
>Any reason this is correct?
>Does anyone face similar behaviour?
>
>Thanks
>Stelios
>

--
Breck Carter [Team iAnywhere]
RisingRoad SQL Anywhere and MobiLink Professional Services
www.risingroad.com
The book: http://www.risingroad.com/SQL_Anywhere_Studio_9_Developers_Guide.html
breck.carter@risingroad.com


Glenn Paulley Posted on 2006-06-26 21:48:57.0Z
Newsgroups: ianywhere.public.general
Subject: Re: Stange behaviour when deviding by SQRT()
From: Glenn Paulley <paulley@ianywhere.com>
References: <449a45f0@forums-2-dub>
Organization: iAnywhere Solutions
Message-ID: <Xns97EEB465C9569paulleyianywherecom@10.22.241.106>
User-Agent: Xnews/5.04.25
X-Original-NNTP-Posting-Host: paulley-t41.sybase.com
X-Original-Trace: 26 Jun 2006 14:44:01 -0700, paulley-t41.sybase.com
Lines: 54
X-Original-NNTP-Posting-Host: forums-2-dub.sybase.com
X-Original-Trace: 26 Jun 2006 14:44:04 -0800, forums-2-dub.sybase.com
NNTP-Posting-Host: forums-master.sybase.com
X-Original-NNTP-Posting-Host: forums-master.sybase.com
Date: 26 Jun 2006 14:48:57 -0700
X-Trace: forums-1-dub 1151358537 10.22.108.75 (26 Jun 2006 14:48:57 -0700)
X-Original-Trace: 26 Jun 2006 14:48:57 -0700, forums-master.sybase.com
X-Authenticated-User: ngsysop
Path: forums-1-dub!not-for-mail
Xref: forums-1-dub ianywhere.public.general:5473
Article PK: 1519

The first two computations are done using type DOUBLE - hence the
residual "2", which is simply an artifact of computation involving
floating point values. In particular, the results of DOUBLE computations
can differ by machine. For example, on Intel chips it is possible to have
effects from residual values from a floating register from a prior
calculation.

The last calculation performs division between a fixed decimal value and
an integer, and is not done using DOUBLE, but with the server's fixed
point math routines.

Glenn

"Stelios Stylianou" <piosarota@piosarota.com.cy> wrote in news:449a45f0
@forums-2-dub:

> Hi all,
>
> I'm using ASA902 build 3221 under WINXP
>
> I execute the following SQL statement in dbisqlg.exe
>
> SELECT SQRT(9),
> (4800.18 / SQRT(9)) as col1,
> (4800.18 / ROUND(SQRT(9), 0)) as clo2,
> (4800.18 / 3) as clo3;
>
> The results are:
> SQRT(9) col1 clo2
> clo3
> 3.0 1600.0600000000002 1600.0600000000002 1600.0600
>
> Any reason this is correct?
> Does anyone face similar behaviour?
>
> Thanks
> Stelios
>
>

--
Glenn Paulley
Research and Development Manager, Query Processing
iAnywhere Solutions Engineering

Register now for TechWave 2006 August 6-10 in Las Vegas. New! 2-day
and 4-day options for SQL Anywhere technical training. Sessions will
focus on data management, data movement, and SQL Anywhere 10. Visit
www.sybase.com/techwave

EBF's and Patches: http://downloads.sybase.com
choose SQL Anywhere Studio >> change 'time frame' to all