how it can done without using any arithmetic operation ?
--
You received this message because you are subscribed to the Google Groups
Algorithm Geeks group.
To post to this group, send email to algogeeks@googlegroups.com.
To unsubscribe from this group, send email to
@hary
check sunny's solution and for '+' do with bitwise operators.
On Tue, Jul 12, 2011 at 4:11 PM, hary rathor harry.rat...@gmail.com wrote:
how it can done without using any arithmetic operation ?
--
You received this message because you are subscribed to the Google Groups
Algorithm
correction:
if(a/b=1){
return a%b;
}
else
(a/b)*b + a%b;
assumption that difference is positive everytime
On Tue, Jul 12, 2011 at 10:29 AM, Dave dave_and_da...@juno.com wrote:
@Chandy: Let a = 5 and b = 3. Then x = 5 - 3 = (5/3)*3 + 5%3 = 1*3 + 2
= 5. Check?
Dave
On Jul 11, 11:38 pm,
Lets Try For Decimal Integer Number how we add them
1 Add 759 + 674, but “forget” to carry I then get 323
2 Add 759 + 674 but only do the carrying, rather than the addition of
each digit I then
get 1110
3 Add the result of the first two operations (recursively, using the
same process de-
awesum :) thanx all
On Tue, Jul 12, 2011 at 8:27 PM, bittu shashank7andr...@gmail.com wrote:
Lets Try For Decimal Integer Number how we add them
1 Add 759 + 674, but “forget” to carry I then get 323
2 Add 759 + 674 but only do the carrying, rather than the addition of
each digit I then
@Aditya: Since 124 is a 3-digit number, I think it would make more
sense to use the 3-digit 10's complement of 46, i.e., 954. Then 124 +
954 = 1078. Since we are working in 3-digit numbers, the 1 represents
an overflow, which you ignore. Thus, the answer is 78.
Dave
On Jul 11, 2:42 pm, aditya
Y are u guys complicating things.Its as simple as this
x=a-b = (a/b)*b + a%b
On Tue, Jul 12, 2011 at 1:18 AM, Dave dave_and_da...@juno.com wrote:
@Aditya: Since 124 is a 3-digit number, I think it would make more
sense to use the 3-digit 10's complement of 46, i.e., 954. Then 124 +
954 =
@Chandy: Let a = 5 and b = 3. Then x = 5 - 3 = (5/3)*3 + 5%3 = 1*3 + 2
= 5. Check?
Dave
On Jul 11, 11:38 pm, chandy jose paul jpchaa...@gmail.com wrote:
Y are u guys complicating things.Its as simple as this
x=a-b = (a/b)*b + a%b
On Tue, Jul 12, 2011 at 1:18 AM, Dave
i would say.. implementing subtraction using division and modulus is more
costly and complicated. bit manipulation is the fastest among all
these techniques.
x=a-b = (a/b)*b + a%b
.here u are performing... totally 4 operations..1 division,1
multiplication,1 modulus and 1 addition..
it can
z = x + (-y)
:)
On Tue, Jul 12, 2011 at 10:58 AM, Sunny T sunny.1...@gmail.com wrote:
i would say.. implementing subtraction using division and modulus is more
costly and complicated. bit manipulation is the fastest among all
these techniques.
x=a-b = (a/b)*b + a%b
.here u are
10 matches
Mail list logo