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

Problem in converting float4 type to float8

P: 18
Hi Friends,

when I have convert the float4 data type to float8 data type it was lossing the value. The following are the commands i Have used. Plaese go through it.

(1) TE TABLE tab1(id int PRIMARY KEY,val float4);

(2) INSERT INTO tab1 VALUES(1,1.1);
INSERT INTO tab1 VALUES(2,1.2);
INSERT INTO tab1 VALUES(3,1.3);

(3) When I Use the SELECT COMMAND (SELECT * FROM tab1) It was showing the Correct values.

(4) After That I have issued the following command to change the data type of val from float4 to float8. The following is the command.

ALTER TABLE tab1 ALTER COLUMN val TYPE float8;

(5) When I Issue the SELECT COMMAND it was showing a little bit wrong values(in precision) like the following

1.1000000
1.20000023
1.29999 (in the place of 1.3)

instead of 1.3 it was showing a value which is less.



please tell me what is the reason.

Thank You
Dec 8 '07 #1
Share this Question
Share on Google+
1 Reply


Expert 100+
P: 700
Hi Friends,

when I have convert the float4 data type to float8 data type it was lossing the value. The following are the commands i Have used. Plaese go through it.

(1) TE TABLE tab1(id int PRIMARY KEY,val float4);

(2) INSERT INTO tab1 VALUES(1,1.1);
INSERT INTO tab1 VALUES(2,1.2);
INSERT INTO tab1 VALUES(3,1.3);

(3) When I Use the SELECT COMMAND (SELECT * FROM tab1) It was showing the Correct values.

(4) After That I have issued the following command to change the data type of val from float4 to float8. The following is the command.

ALTER TABLE tab1 ALTER COLUMN val TYPE float8;

(5) When I Issue the SELECT COMMAND it was showing a little bit wrong values(in precision) like the following

1.1000000
1.20000023
1.29999 (in the place of 1.3)

instead of 1.3 it was showing a value which is less.



please tell me what is the reason.

Thank You

see here at postgresql.org
Dec 9 '07 #2

Post your reply

Sign in to post your reply or Sign up for a free account.