IBM Mainframe Forum Index
 
Log In
 
IBM Mainframe Forum Index Mainframe: Search IBM Mainframe Forum: FAQ Register
 

Convertion of big value in Float to decimal


IBM Mainframe Forums -> DB2
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
Silvia Mello

New User


Joined: 19 Jan 2009
Posts: 1
Location: Brazil

PostPosted: Thu Feb 19, 2009 6:14 pm
Reply with quote

Hi there,
Please, I need some help.
I'm using SPUFI and I'm trying to Select a column that is Float. I need to see the value in Decimal format. I'm not sure which scalar function I could use. I've tried DEC but I noticed that it's truncating the result:
---------+---------+---------+---------+---------+---------+
CREATE TABLE A151673.TESTE_FLOAT
(COL01 FLOAT(23));
---------+---------+---------+---------+---------+---------+
DSNE616I STATEMENT EXECUTION WAS SUCCESSFUL, SQLCODE IS 0
---------+---------+---------+---------+---------+---------+
INSERT INTO A151673.TESTE_FLOAT
VALUES (1234567890123456789);
---------+---------+---------+---------+---------+---------+
DSNE615I NUMBER OF ROWS AFFECTED IS 1
DSNE616I STATEMENT EXECUTION WAS SUCCESSFUL, SQLCODE IS 0
---------+---------+---------+---------+---------+---------+
SELECT DECIMAL(COL01, 19) , COL01
FROM A151673.TESTE_FLOAT;
---------+---------+---------+---------+---------+---------+
COL01
---------+---------+---------+---------+---------+---------+
1234567890123460000, +0,1234567890123457E+19
DSNE610I NUMBER OF ROWS DISPLAYED IS 1

Noticed that although the number I've inserted was 1234567890123456789, the number displayed was 1234567890123460000.
Does anyone know how to solve this problem?
Thanks in advance!
Back to top
View user's profile Send private message
enrico-sorichetti

Superior Member


Joined: 14 Mar 2007
Posts: 10873
Location: italy

PostPosted: Thu Feb 19, 2009 6:29 pm
Reply with quote

review the rules about floating point representation
... loss of significance/precision
( and different Floating point standards )
Back to top
View user's profile Send private message
Bharath Bhat

Active User


Joined: 20 Mar 2008
Posts: 283
Location: chennai

PostPosted: Thu Feb 19, 2009 6:52 pm
Reply with quote

I think you can use CAST function.

Read more about CAST.
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic View Bookmarks
All times are GMT + 6 Hours
Forum Index -> DB2

 


Similar Topics
Topic Forum Replies
No new posts Extracting Variable decimal numbers f... DFSORT/ICETOOL 17
No new posts Need Help with Packed Decimal Signs DFSORT/ICETOOL 4
No new posts Select a DB2 value in a specific deci... DB2 4
No new posts String has hex character need to conv... COBOL Programming 3
No new posts How to display the leading zeros of a... DB2 7
Search our Forums:

Back to Top