471,354 Members | 2,215 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

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

Displaying a float8 as a full-length number

Hello,

I need to get a float8 to display as a number

db=# SELECT CAST('0.00001' AS float8);
float8
--------
1e-05
(1 row)
I need this to return 0.00001 instead. I know about the to_char
function, but this seems to truncate the number after fourteen digits of
precision:
db=# SELECT CAST('0.000000000000001' AS float8);
float8
--------
1e-15
(1 row)

db=# SELECT to_char(CAST('0.000000000000001' AS float8),
CAST('0.9999999999999999999999999' AS text));
to_char
-------------------
0.00000000000000
(1 row)
Does anyone have any suggestions?

Thanks,
Grant
--
Grant Rutherford
Iders Incorporated
600A Clifton Street
Winnipeg, MB
R3G 2X6
http://www.iders.ca
tel: 204-779-5400 ext 36
fax: 204-779-5444
================================
Iders Incorporated: Confidential
================================
Note: This message is intended solely for the use of the designated
recipient(s) and their appointed delegates, and may contain
confidential information. Any unauthorized disclosure, copying or
distribution of its contents is strictly prohibited. If you have
received this message in error, please destroy it and advise the sender
immediately by phone, Email or facsimile.

---------------------------(end of broadcast)---------------------------
TIP 2: you can get off all lists at once with the unregister command
(send "unregister YourEmailAddressHere" to ma*******@postgresql.org)

Nov 12 '05 #1
3 2442
Grant,

Cast it to numeric instead of float8.
SELECT CAST('0.00001' AS numeric);

Julie

---------------------------(end of broadcast)---------------------------
TIP 1: subscribe and unsubscribe commands go to ma*******@postgresql.org

Nov 12 '05 #2
On Wed, Oct 08, 2003 at 12:48:09 -0500,
Grant Rutherford <gr*********@iders.ca> wrote:

I need this to return 0.00001 instead. I know about the to_char
function, but this seems to truncate the number after fourteen digits of
precision:


How about casting it to numeric? It seemed to work reasonably for me,
but I only tried one case.

---------------------------(end of broadcast)---------------------------
TIP 9: the planner will ignore your desire to choose an index scan if your
joining column's datatypes do not match

Nov 12 '05 #3
Julie May wrote:
Grant,

Cast it to numeric instead of float8.
SELECT CAST('0.00001' AS numeric);

Julie

---------------------------(end of broadcast)---------------------------
TIP 1: subscribe and unsubscribe commands go to ma*******@postgresql.org

Thanks, that worked perfectly.

--
Grant Rutherford
Iders Incorporated
600A Clifton Street
Winnipeg, MB
R3G 2X6
http://www.iders.ca
tel: 204-779-5400 ext 36
fax: 204-779-5444
================================
Iders Incorporated: Confidential
================================
Note: This message is intended solely for the use of the designated
recipient(s) and their appointed delegates, and may contain
confidential information. Any unauthorized disclosure, copying or
distribution of its contents is strictly prohibited. If you have
received this message in error, please destroy it and advise the sender
immediately by phone, Email or facsimile.


---------------------------(end of broadcast)---------------------------
TIP 9: the planner will ignore your desire to choose an index scan if your
joining column's datatypes do not match

Nov 12 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

3 posts views Thread by Pat Sheen | last post: by
8 posts views Thread by Jon Weston | last post: by
11 posts views Thread by Usenet User | last post: by
reply views Thread by XIAOLAOHU | 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.