444,225 Members | 2,223 Online
Need help? Post your question and get tips & solutions from a community of 444,225 IT Pros & Developers. It's quick & easy.

# reading float point from file

 P: n/a Hi, the file that i read has the following column as input: 1.000005 1.00001 1.000015 1.00002 1.000025 Now I have float variable skew. When i read in from the file as inFile >>skew; I read in following values: Skew read= 1.00001 Skew read= 1.00001 Skew read= 1.00002 Skew read= 1.00002 So it rounds up to the 5th decimal position . Why? I know it might have something to do with the insuffereable precision of float points. But is there some easy way of gettin to read the correct value from the file and not go to BCD? Similarly when i do float x= skew-1, I get something which is not nearly like 0.00001, but a close approximation. Again how can i get the correct value? Thanks Affan Jul 22 '05 #1
6 Replies

 P: n/a actually the reading from file was okay... it read in the right value... but when i debug it .. it just showed uptil a precision of 7 decimal points.. so when i changed the precision of cout to 8, it printed the correctly rounded values... So that is solved... however.. how do i do the maths with it... as simple as subtracting one form it!!!? regards Affan "Affan Syed" wrote in message news:co**********@gist.usc.edu... Hi, the file that i read has the following column as input: 1.000005 1.00001 1.000015 1.00002 1.000025 Now I have float variable skew. When i read in from the file as inFile >>skew; I read in following values: Skew read= 1.00001 Skew read= 1.00001 Skew read= 1.00002 Skew read= 1.00002 So it rounds up to the 5th decimal position . Why? I know it might have something to do with the insuffereable precision of float points. But is there some easy way of gettin to read the correct value from the file and not go to BCD? Similarly when i do float x= skew-1, I get something which is not nearly like 0.00001, but a close approximation. Again how can i get the correct value? Thanks Affan Jul 22 '05 #2