![]() |
| | #16 |
| Anti-Poster Join Date: Feb 2002
Posts: 1,241
| Code: operand [*,/] operand operand -> a constant, one of the inputs, or operand [*,/] operand I will share my original thoughts. Since a double contains 11 bits of exponent, that part of a double can be used as an accumulator through multiplication. Note that not all states of the 11 bits are valid; I originally planned to only use 10 bits to avoid the NaN and infinity states. After building a 10-bit accumulator, it's a simple step to cascade five of them, add a three bit accumulator for the last three bits that the fraction part of a double can contain, and perform the addition in that context. This required the comparision operators to check to see if the initial state of the exponent was 0 since multiplying 0 by 2 wouldn't produce any usable input. The assignment operator was necessary to assign the first 1 into an empty accumulator. Of course, with the comparision and assignment operators, you really don't need anything that convolted. A union with a bit field (with each bit as its own field) and a 64-bit integer would provide the space needed to perform the addition.
__________________ Rule #1: Every rule has exceptions |
| pianorain is offline | |
| | #17 |
| Registered User Join Date: Sep 2001
Posts: 752
| I'm inclined to say it's impossible as well... but for the life of me, I just can't prove it. On the other hand, if you only use pow() and ln(), you can do this easily.
__________________ Callou collei we'll code the way Of prime numbers and pings! |
| QuestionC is offline | |
| | #18 | |
| Senior software engineer Join Date: Mar 2007 Location: Portland, OR
Posts: 5,768
| Quote:
Take, for instance, the expression 1 - 1. There simply is no sequence of multiplication and division operations on the value 1 that will ever result in zero. (Unless you multiply by zero somewhere, but that's hardly a general method either). | |
| brewbuck is offline | |
| | #19 |
| aoeuhtns Join Date: Jul 2005
Posts: 581
| The proof is pretty simple: Multiplying and dividing nonzero numbers produces a nonzero result. Thus you can't get the sum of 1 and -1 with only multiplication and division, unless you multiply by zero (and then your function adds everything to zero). You need some additional features, like control structures and comparison operators, to make progress towards zero. Edit: beaten. Edit 2: Hey, the ICFP contest has begun.
__________________ There are 10 types of people in this world, those who cringed when reading the beginning of this sentence and those who salivated to how superior they are for understanding something as simple as binary. |
| Rashakil Fol is offline | |
| | #20 |
| </3 Segfaults Join Date: Jul 2007
Posts: 27
| Ints -> Rounding -> Zero. |
| Differ is offline | |
| | #21 |
| Senior software engineer Join Date: Mar 2007 Location: Portland, OR
Posts: 5,768
| |
| brewbuck is offline | |
| | #22 |
| Registered User Join Date: Aug 2007 Location: Barbados
Posts: 30
| No Fear! I am here to save the Day! *sea_4_ever rides up on a white horse. I WILL ATTEMPT THIS! so, am I allowed to use more than one variable? I will need at least 7; At least I think this can be solved with something similar to Pythagoras' Theorem. A^2 + B^2 = C^2 So maybe : ((A^2)/B) * ((B^2)/A) = C ... *sea_4_ever goes back to his notes EDIT4: I am inclined to give up. EDIT5 : maybe if I use that fibonacci series. multiply the first number by the ratio, and then divide the answer by the third number... erhm, what is the prize? BUT I NEVER GIVE UP! Last edited by sea_4_ever; 08-28-2007 at 02:05 PM. |
| sea_4_ever is offline | |
| | #24 | ||
| Dr Dipshi++ Join Date: Oct 2006 Location: On me hyperplane
Posts: 1,219
| Quote:
Think of this: Quote:
| ||
| mike_g is offline | |
| | #25 |
| Unregistered User Join Date: Jul 2007
Posts: 982
| ![]() Code: void SubtractOne(DWORD *pdwQuery) {
*pdwQuery *= 0.99999999999999; }
__________________ May the Source be with you. |
| Yarin is offline | |
| | #26 |
| </3 Segfaults Join Date: Jul 2007
Posts: 27
| Ah, I just came back and saw the "doubles" part. Many apologies; my solution will only work for integers. |
| Differ is offline | |
| | #27 |
| MENTAL DETECTOR Join Date: Apr 2006 Location: United States
Posts: 3,295
| Pardon me, but I don't think the type makes a difference at all. No amount of fudging can make -1 * 1 give the same result as 1 - 1. Of course abachler never said that you had to use the same terms as your input, however addition and subtraction treat the sign of a number fundamentally different than multiplication or division. If it's logically incomprehensible I doubt there is a reliable implementation that works for any combonation of 10,000 numbers. Whatever the range was. Writing this for the fourth or fifth time now, I hope this thread has used up the last of its lives. |
| whiteflags is offline | |
![]() |
| Thread Tools | |
| Display Modes | |
|
Similar Threads | ||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Faster way to divide numbers | scwizzo | C++ Programming | 3 | 04-29-2009 11:45 AM |
| Overflow and range checking for mul/div | Elysia | C++ Programming | 28 | 06-06-2008 02:09 PM |
| working with rotation matrices | hannibar | Game Programming | 23 | 03-30-2005 01:10 PM |
| How to multiply and Divide Huge int numbers | Dewayne | C++ Programming | 3 | 10-21-2004 08:41 PM |
| calculator in c++ | gamer | C++ Programming | 11 | 02-19-2003 10:46 AM |