Division anomally

forum.sqlbase (2000-2010)
NewsgroupServer
Robot
Robot
Posts: 118939
Joined: 24 Feb 2017, 12:00
Location: World wide

Division anomally

Post by NewsgroupServer » 05 Mar 2010, 17:18

 Posted by:  Athanasios Papadopoulos 

Have created a table using talk 9.0.1 built 13765

CREATE TABLE SYSADM.TEST (
ID INTEGER NOT NULL,
CURRAMNT DECIMAL(15, 2) NOT NULL,
USDAMNT DECIMAL(15, 2) NOT NULL)
PCTFREE 10
/
Have inserted below rows

INSERT INTO TEST (ID, CURRAMNT, USDAMNT ) VALUES ( 1, 319.25, 459.21);
INSERT INTO TEST (ID, CURRAMNT, USDAMNT) VALUES ( 2, 59.90, 82.07);
INSERT INTO TEST (ID, CURRAMNT, USDAMNT) VALUES ( 3, 6837.48, 6837.48);

Then have added a column patity

alter table TEST ADD parity DECIMAL(15,4);

Running below command to update the parity for all parities:

update TEST set parity = @ROUND(CURRAMNT/ USDAMNT,4);
or even

update TEST set parity = CURRAMNT/ USDAMNT;

I get odd results i.e. no decimal points are calculated. The result of
select is as follows:

ID CURRAMNT USDAMNT PARITY
=========== =============== =============== ===============
1 319.25 459.21
0 (correct figure 0.6952)
2 59.90 82.07
0 (correct figure 0.7299)
3 6837.48 6837.48
1

Does anybody have any idea or should I post a bug

Thanks
Athanasios

NewsgroupServer
Robot
Robot
Posts: 118939
Joined: 24 Feb 2017, 12:00
Location: World wide

Division anomally

Post by NewsgroupServer » 05 Mar 2010, 17:22

 Posted by:  Athanasios Papadopoulos 

The SqlBase is 9.0.1PTF2.Built 13767

NewsgroupServer
Robot
Robot
Posts: 118939
Joined: 24 Feb 2017, 12:00
Location: World wide

Division anomally

Post by NewsgroupServer » 25 May 2010, 19:14

 Posted by:  Geert Schroeder 

Hello Athanasios,

Try :
update TEST set parity = 1.0 * CURRAMNT/ USDAMNT;

(it's a kind of special feature)

Best Regards
Geert

Return to “forum.sqlbase”

Who is online

Users browsing this forum: Ccbot [Crawler] and 0 guests