Division, Remainders and only Real Numbers Allowed

Posted by Senica Gonzalez on Stack Overflow See other posts from Stack Overflow or by Senica Gonzalez
Published on 2010-04-02T21:51:25Z Indexed on 2010/04/02 21:53 UTC
Read the original article Hit count: 399

Filed under:
|
|

Trying to figure out this pseudo code. The following is assumed.... I can only use unsigned and signed integers (or long). Division returns a real number with no remainder. MOD returns a real number. Fractions and decimals are not handled.

INT I = 41828;
INT C = 15;
INT D = 0;

D = (I / 65535) * C;

How would you handle a fraction (or decimal value) in this situation? Is there a way to use negative value to represent the remainder?

In this example I/65535 should be 0.638, however, with the limitations, I get 0 with a MOD of 638. How can I then multiply by C to get the correct answer?

Hope that makes sense.

© Stack Overflow or respective owner

Related posts about division

Related posts about remainder