Hi,
You made this question a long time ago, but I used your code to understand what was wrong with mine. Finally, I got accepted and in the process I found your bug (well, at least one bug - and, of course you may have found it already, but this can help someone else):
In same cases, your angle ...
Search found 2 matches
- Fri Nov 03, 2006 1:42 pm
- Forum: Volume 108 (10800-10899)
- Topic: 10834 - The Story of Two Coins
- Replies: 18
- Views: 6077
- Wed Nov 01, 2006 5:26 pm
- Forum: Volume 108 (10800-10899)
- Topic: 10823 - Of Circles and Squares
- Replies: 50
- Views: 17848
When does round() fail
You have problems with rounding. Using floating point in this problem is kind of lottery.
Here's a rounding function which does not make use of any floats.
int round1(int p, int q) /* Rounds fraction p/q */
{
return (p / q) + (((2 * (p % q)) >= q) ? 1 : 0);
}
Hi,
first I had something like ...
Here's a rounding function which does not make use of any floats.
int round1(int p, int q) /* Rounds fraction p/q */
{
return (p / q) + (((2 * (p % q)) >= q) ? 1 : 0);
}
Hi,
first I had something like ...