473,788 Members | 3,053 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 "MagicFunct ion" in the
following pseudocode:

myVarchar = MagicFunction(1 23.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.ib m.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.as c of del select
substr(char(col 1),1,1) from testdoub

db2 export to c:\tmp\chari.as c 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.180860635940 92E-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 11662
Try decimal(float_c ol_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 "MagicFunct ion" in the
following pseudocode:

myVarchar = MagicFunction(1 23.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.ib m.com> wrote in message
news:3B****** *********@ca.ib m.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.as c of del select
substr(char(col 1),1,1) from testdoub

db2 export to c:\tmp\chari.as c 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.180860635940 92E-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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
13928
by: matt melton | last post by:
Hi there, I am trying to write a method that accepts an array of any primitive type and will return the same array without copying memory as an array of bytes. ie. I'd like to be able to do something like: char chars = "Hello!"; byte bytes = (byte) chars;
7
505
by: john | last post by:
On my form i have a message box called txtItemDesc that displays the french phrase qualité Père Noël. Now then when i run this code on that text box: Dim chrArr() As Char chrArr = txtItemDesc.Text.ToCharArray Dim pos As Integer While pos < chrArr.Length Dim c As Char MsgBox(Asc(chrArr(pos)) & " " & chrArr(pos)) pos = pos + 1
17
16618
by: Jon Slaughter | last post by:
I'm having a little trouble understanding what the slicing problem is. In B.S.'s C++ PL3rdEd he says "Becayse the Employee copy functions do not know anything about Managers, only the Employee part of Manager is copied. ".... and gives the code above as .....
0
3941
by: Lokkju | last post by:
I am pretty much lost here - I am trying to create a managed c++ wrapper for this dll, so that I can use it from c#/vb.net, however, it does not conform to any standard style of coding I have seen. It is almost like it is trying to implement it's own COM interfaces... below is the header, and a link to the dll+code: Zip file with header, example, and DLL:...
4
3489
by: Kivanc Toker | last post by:
Hi, I've got a problem with displaying texts with turkish characters. There is a website administration system, which is developed using ASP (VBScript) and ADO. This system is being used for inserting product informations in to a ms-sql database. There is another webbased application, which is developed using ASP.NET and ADO.NET (C#). For this second application there is a separate ms-sql
2
2361
by: James Radke | last post by:
Hello, I have a vb.net windows application that is calling an older DLL provided by a third party. They supplied a VB 6 application that, when run on my systemn successfully passes data to the database. The problem I am having is that when I pass the data from VB.NET, the fields defined as double all contain strange values. For example, if I pass in 10, the value stored on the database is: 5.325550197128e-315 Note that most of the...
2
1386
by: Brian Blais | last post by:
Hello, I am trying to translate some Matlab/mex code to Python, for doing neural simulations. This application is definitely computing-time limited, and I need to optimize at least one inner loop of the code, or perhaps even rethink the algorithm. The procedure is very simple, after initializing any variables: 1) select a random input vector, which I will call "x". right now I have it as an array, and I choose columns from that array...
39
19647
by: Martin Jørgensen | last post by:
Hi, I'm relatively new with C-programming and even though I've read about pointers and arrays many times, it's a topic that is a little confusing to me - at least at this moment: ---- 1) What's the difference between these 3 statements: (i) memcpy(&b, &KoefD, n); // this works somewhere in my code
7
4787
by: ma740988 | last post by:
Consider the equation (flight dynamics stuff): Yaw (Degrees) = Azimuth Angle(Radians) * 180 (Degrees) / 3.1415926535897932384626433832795 (Radians) There's a valid reason to use single precision floating point types. The number of decimal digits guaranteed to be correct on my implementation is 6. (i.e numeric_limits < float >::digits10 = 6 ) If I'm reading the IEEE standard, I'd could paraphrase the issue
0
9655
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9498
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10172
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10110
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9964
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8993
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
6749
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5398
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5535
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?

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.