By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,831 Members | 1,024 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,831 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
Share this Question
Share on Google+
4 Replies


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

weaknessforcats
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

Savage
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

Savage
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

Post your reply

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