Timeline for Multiply two numbers
Current License: CC BY-SA 3.0
9 events
when toggle format | what | by | license | comment | |
---|---|---|---|---|---|
Nov 30, 2016 at 12:51 | comment | added | craftworkgames | @t3chb0t Yeah, okay, fair enough. But you must admit, the way the OP worded the original question and the follow up comments, it felt like he wasn't being entirely serious about the question. I may have gone too far with that initial comment, but I didn't mean to offend anyone. My apologies. | |
Nov 30, 2016 at 12:44 | history | edited | craftworkgames | CC BY-SA 3.0 |
added 69 characters in body
|
Nov 30, 2016 at 12:00 | comment | added | t3chb0t | Quote: Seriously? Is this a joke? - and you wonder why the DV? | |
Nov 28, 2016 at 20:06 | comment | added | craftworkgames | @Rohit keep in mind that when I wrote this answer you hadn't mentioned anywhere that you didn't want to use the * operator. You even used it in your first method. | |
Nov 28, 2016 at 19:36 | comment | added | craftworkgames | Two down votes? Explanation? | |
Nov 28, 2016 at 15:58 | comment | added | Ron Beyer |
Would be good to note that, even in the OP's original code, this assumes that the operands are non-negative and that the result can be stored in an integer (int.Max * int.Max for example).
|
|
Nov 28, 2016 at 14:54 | comment | added | Rohit | Well I am trying to implement multiplication on my own instead of using * operator. It is more likely a interview question | |
Nov 28, 2016 at 14:38 | comment | added | Jaime |
The asymptotic complexity of MultiplicationUsingAdd is O(min(n, m)) . Long multiplication has space complexity O(log n + log m) , which is pretty damn good, and time complexity O(log n * log m) , which makes it a contender in real life if you are dealing with very large integers, although there are better alternatives, e.g. Karatsuba. Point being, it really is repeated addition that you should never use to multiply two numbers, as there is almost always going to be a better alternative.
|
|
Nov 28, 2016 at 13:53 | history | answered | craftworkgames | CC BY-SA 3.0 |