By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
438,756 Members | 1,745 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 438,756 IT Pros & Developers. It's quick & easy.

problem converting DOUBLE to CHAR

P: n/a
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
Share this Question
Share on Google+
1 Reply


P: n/a
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.