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

# i am writing a c code on data compression algorithm to convert float to int type, can

 P: 1 assume there r two float no. lat1=1300.1252; lat2=1302.2546; After subtracting, the result obtained must be converted to int, which is easily possible by multiplying with pow(10,4),if I get result as 0.2345,what if I get result as 3,8675? Jun 18 '07 #1
4 Replies

 P: 55 I don't understand what u say. Jun 18 '07 #2

 Expert Mod 5K+ P: 9,197 You cannot covert a float value to an int without truncation and possile loss of data since integers have no decimals. Why do you need the integer result?? Jun 18 '07 #3

 Expert 100+ P: 1,764 You cannot covert a float value to an int without truncation and possile loss of data since integers have no decimals. Why do you need the integer result?? If I have understood OP's question correctly,he wont to do this: e.g 3.2456-3.1232=0.0224. Now what OP wont is to multiply this result with such number that it becomes a integer 0.0224*10^4=224. Am I right,muralick? Savage Jun 18 '07 #4

 Expert 100+ P: 1,764 If I have understood OP's question correctly,he wont to do this: e.g 3.2456-3.1232=0.0224. Now what OP wont is to multiply this result with such number that it becomes a integer 0.0224*10^4=224. Am I right,muralick? Savage If I'm rigth,then you will need to analyse resulting float.To determine all important parts,as: what is a integer value of that float,how much there are decimal numbers behind decimal point.For this analyses, because of float number arithmetic, you will need to input it as a string,analyze it and then convert to the float number. Savage Jun 18 '07 #5