473,396 Members | 1,996 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

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

How to convert a DOUBLE to a string with no decimal separators?

Hi all,

I have a table containing MEASURE DOUBLE. I want to

SELECT measure FROM mytable WHERE <condition>

If measure = 1860.45, I get: '1,860.45'. How can I strip the comma? I
tried:

DECIMAL(measure,20,5) still has the comma

CHAR(DECIMAL(measure,20,5)) gives me 000000000001860.48000

strip(char(decimal(measure,20,5)),LEADING,'0') gives me error 440 ("No
authorized routine named 'STRIP' of type 'FUNCTION' having compatible
arguments...)
There must be a way, but I cannot find it. Note that I do not really
know the magnitude of the numbers, thus the 20 and the 5, to make it
"big enough". Also, I read in other postings that DB2 may use the
locale information to format the number; I cannot change the locale so
I must do the formatting after the number is returned by DB2 unless
someone knows better.

Thanks for any help,

Alejandrina

Feb 5 '07 #1
2 22576
On Feb 5, 3:06 pm, "apattin" <apat...@gmail.comwrote:
Hi all,

I have a table containing MEASURE DOUBLE. I want to

SELECT measure FROM mytable WHERE <condition>

If measure = 1860.45, I get: '1,860.45'. How can I strip the comma? I
tried:

DECIMAL(measure,20,5) still has the comma

CHAR(DECIMAL(measure,20,5)) gives me 000000000001860.48000

strip(char(decimal(measure,20,5)),LEADING,'0') gives me error 440 ("No
authorized routine named 'STRIP' of type 'FUNCTION' having compatible
arguments...)

There must be a way, but I cannot find it. Note that I do not really
know the magnitude of the numbers, thus the 20 and the 5, to make it
"big enough". Also, I read in other postings that DB2 may use the
locale information to format the number; I cannot change the locale so
I must do the formatting after the number is returned by DB2 unless
someone knows better.

Thanks for any help,

Alejandrina
Will "SELECT DIGITS(measure) FROM mytable WHERE <condition>" work for
you? I'm not sure what client tool you're using (just CLP?), but I
wonder if it's responsible for putting in the comma, not DB2 per se.

--Jeff

Feb 5 '07 #2
apattin wrote:
Hi all,

I have a table containing MEASURE DOUBLE. I want to

SELECT measure FROM mytable WHERE <condition>

If measure = 1860.45, I get: '1,860.45'. How can I strip the comma? I
tried:

DECIMAL(measure,20,5) still has the comma

CHAR(DECIMAL(measure,20,5)) gives me 000000000001860.48000

strip(char(decimal(measure,20,5)),LEADING,'0') gives me error 440 ("No
authorized routine named 'STRIP' of type 'FUNCTION' having compatible
arguments...)
There must be a way, but I cannot find it. Note that I do not really
know the magnitude of the numbers, thus the 20 and the 5, to make it
"big enough". Also, I read in other postings that DB2 may use the
locale information to format the number; I cannot change the locale so
I must do the formatting after the number is returned by DB2 unless
someone knows better.
I believe that's an environment configuration thing in your environment.
Check the character that is set as 1000-separator in your regional
settings.

$ db2 "values double(1234567.90)"

1
------------------------
+1.23456790000000E+006

$ db2 "values decimal(double(1234567.90), 10, 2)"

1
------------
1234567.90
--
Knut Stolze
DB2 z/OS Utilities Development
IBM Germany
Feb 6 '07 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

7
by: hana1 | last post by:
Hello experts, I used to program in C/C++ and now switched to Java. I am having a difficulty that I need your help with. How can I limit a double variable to hold 2 decimal points only? Say I...
3
by: jeff_zhang446 | last post by:
Hi, I try to convert double to string as below: std::string cnvrtToString(double lValue) { std::ostringstream lStream; lStream << lValue; return lStream.str();
4
by: STom | last post by:
How do you convert a string in C# to decimal? STom
3
by: mlafarlett | last post by:
In the example below, the 'convert.ToDecimal' removes the trailing 5. I'd like to get the number, in tact, moved to the decimal variable. Any help would be greatly appreciated. Dim dcml As...
6
by: Jim Stools | last post by:
How do I do this: result needs to be a decimal to 2 places? I get casting problems on the below: double myPrice = 1200.125;double myShares = 354.288; decimal myTotal; myTotal = myPrice *...
6
by: Mark Chimes | last post by:
Hi All, I need to search thru some strings and discard them if they canot be converted to a decimal or interger value. What is the best way to do this? cheers, Mark Chimes
2
by: Poz | last post by:
Is there a way to convert an exponential number (held in string format) to non-exponential format without losing any precision in the number? For example, I have a string variable containing...
10
by: cmdolcet69 | last post by:
Public ArrList As New ArrayList Public bitvalue As Byte() Public Sub addvalues() Dim index As Integer ArrList.Add(100) ArrList.Add(200) ArrList.Add(300) ArrList.Add(400) ArrList.Add(500)
3
by: Mike Howarth | last post by:
Hi Seem to be having a bit of brainfreeze this evening. Basically I'm reducing an array of prices like so: This gives me a string of '86.00.00' which I am trying to use with decimal...
1
by: Bjorn Brox | last post by:
Hi! In germany, norway and France(?) we are using ',' as decimal separator and it always messes up when you convert a double to and from a string where the interface expects double values stored...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
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...
0
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...
0
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,...

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.