472,119 Members | 1,436 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,119 software developers and data experts.

problem converting DOUBLE to CHAR

Hi,

I saw this post from 3 years ago regarding converting DOUBLE values to
CHAR in ibm DB2. Now I'm having the same problem. No real solution
was posted to that old thread. Has anyone got more information how I
avoid the scientific notation when I use the CHAR() function to
convert a DOUBLE or FLOAT ? What I want is "MagicFunction" in the
following pseudocode:

myVarchar = MagicFunction(123.0003);
print myVarchar -> outputs "123.0003"

myVarchar = MagicFunction(2);
print myVarchar -> outputs "2"

Thanks,

Kent Lewandowski

---

Have you tried casting to BIGINT or the largest possible DEC?

Dmitry wrote:
I have large double numbers, so int() and dec() functions return 0. Any
other way?

Thank you,
Dmitry.

"Blair Kenneth Adamache" <ad******@ca.ibm.com> wrote in message
news:3B***************@ca.ibm.com...
You could cast it to an int, dec or a char. Casting to a numeric value (INT or
DEC) makes more sense:

db2 export to c:\tmp\chard.asc of del select
substr(char(col1),1,1) from testdoub

db2 export to c:\tmp\chari.asc of del select
int(col1) from testdoub

Dmitry wrote:
Hi,

When I export table to text file (using db2 export command) I get scientific
notation for double values like +1.18086063594092E-006.
Does anybody know how to avoid the E-006 part? I use DB2 v6.1 on Win2000.

Best regards, Dmitry.

Nov 12 '05 #1
1 11367
Try decimal(float_col_name[,precision[,scale]]).

precision values from 1-31, scale from 0 to precision.

Simple put; precision is the column width, scale is digits to the right
of the decimal.

Have a good look at the SQL Reference, Vol 1 for information about all
of the supplied functions.
Phil Sherman

Kent Lewandowski wrote:
Hi,

I saw this post from 3 years ago regarding converting DOUBLE values to
CHAR in ibm DB2. Now I'm having the same problem. No real solution
was posted to that old thread. Has anyone got more information how I
avoid the scientific notation when I use the CHAR() function to
convert a DOUBLE or FLOAT ? What I want is "MagicFunction" in the
following pseudocode:

myVarchar = MagicFunction(123.0003);
print myVarchar -> outputs "123.0003"

myVarchar = MagicFunction(2);
print myVarchar -> outputs "2"

Thanks,

Kent Lewandowski

---

Have you tried casting to BIGINT or the largest possible DEC?

Dmitry wrote:

I have large double numbers, so int() and dec() functions return 0. Any
other way?

Thank you,
Dmitry.

"Blair Kenneth Adamache" <ad******@ca.ibm.com> wrote in message
news:3B***************@ca.ibm.com...
You could cast it to an int, dec or a char. Casting to a numeric value (INT or
DEC) makes more sense:

db2 export to c:\tmp\chard.asc of del select
substr(char(col1),1,1) from testdoub

db2 export to c:\tmp\chari.asc of del select
int(col1) from testdoub

Dmitry wrote:
Hi,

When I export table to text file (using db2 export command) I get scientific
notation for double values like +1.18086063594092E-006.
Does anybody know how to avoid the E-006 part? I use DB2 v6.1 on Win2000.

Best regards, Dmitry.


Nov 12 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

5 posts views Thread by matt melton | last post: by
7 posts views Thread by john | last post: by
17 posts views Thread by Jon Slaughter | last post: by
4 posts views Thread by Kivanc Toker | last post: by
2 posts views Thread by Brian Blais | last post: by
39 posts views Thread by Martin Jørgensen | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.