Email: Password: Remember Me | Create Account (Free)

Back to Subject List

Old thread has been locked -- no new posts accepted in this thread
???
11/07/08 10:31
Modified:
  11/07/08 10:33

Read: times


 
#159886 - You could solve it using long
Responding to: ???'s previous message
However, you need to decide before hand how many decimal digits you need. Then you could simplify the calculation as

R = (C/2 * (long)V)/D

where R and D are declared as long variables. This calculation will only yield the integer part of the result. Let us assume the answer to be 123.45 You will only get 123 with the above equation.

To capture the decimal fraction, you have to do something like this

R = (C/2 * (long)V * 2474)/D

which will give you 3 decimal digits. So the answer would be 123450. To split it you get the integer part as R/1000 and the fraction as R modulo 1000.

PS: I see Per Westermark posted just ahead of me. Moreover, I forgot to include your factor of 2.474 which I just did. It is 2.474*1000 in the above equation

List of 6 messages in thread
TopicAuthorDate
Help need!            01/01/70 00:00      
   be more specific            01/01/70 00:00      
      That is correct!            01/01/70 00:00      
   32-bit fixed point            01/01/70 00:00      
   You could solve it using long            01/01/70 00:00      
      Re: You could solve it using long            01/01/70 00:00      

Back to Subject List