Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.c > #15810

Re: RELATION BETWEEN OPERATORS

From Dr Nick <3-nospam@temporary-address.org.uk>
Newsgroups comp.lang.c
Subject Re: RELATION BETWEEN OPERATORS
Date 2012-01-15 10:21 +0000
Message-ID <87ipkdp8oz.fsf@temporary-address.org.uk> (permalink)
References <a1a4c454-f03c-4fbe-a936-f671b1de8433@v6g2000pba.googlegroups.com>

Show all headers | View raw


ishwar mehta <imehta285@gmail.com> writes:

> HI FRIENDS,SOMEWHERE i have Seen that

In your homework assignment?

> Expressions  (x%8) and (x&7)  in C , are equivalent.. that is

They aren't.

>  if i write a program like
>
>
> int main ()
> {
>    int x=50;

try it with x=-50 and you'll see the difference.

>  printf("%d\n", x%8);
>  printf("%d\n", x&7);
>  return 0 ;
> }
> output:
> 2
> 2
>
> SO Frnd,plz help me to figure out ,what is the exact relation betwwen
> the  operators  % and & .

What does the % operator do?

What does the & operator do?

Why will they give the same results for some range of values (NB, this
is maths rather than C).

> plzzzzzzz.......

Can you take that bee out of here please, it's driving me nuts.
-- 
Online waterways route planner            | http://canalplan.eu
Plan trips, see photos, check facilities  | http://canalplan.org.uk

Back to comp.lang.c | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread


Thread

RELATION BETWEEN OPERATORS ishwar mehta <imehta285@gmail.com> - 2012-01-15 01:54 -0800
  Re: RELATION BETWEEN OPERATORS Dr Nick <3-nospam@temporary-address.org.uk> - 2012-01-15 10:21 +0000
  Re: RELATION BETWEEN OPERATORS "BartC" <bc@freeuk.com> - 2012-01-15 10:51 +0000
    Re: RELATION BETWEEN OPERATORS Ben Bacarisse <ben.usenet@bsb.me.uk> - 2012-01-15 13:42 +0000
      Re: RELATION BETWEEN OPERATORS Peter Nilsson <airia@acay.com.au> - 2012-01-17 18:19 -0800
  Re: RELATION BETWEEN OPERATORS Nick Keighley <nick_keighley_nospam@hotmail.com> - 2012-01-15 04:01 -0800
  RELATION BETWEEN OPERATORS John Bode <jfbode1029@gmail.com> - 2012-01-16 09:11 -0800
    Re: RELATION BETWEEN OPERATORS Keith Thompson <kst-u@mib.org> - 2012-01-16 12:03 -0800
      Re: RELATION BETWEEN OPERATORS John Bode <jfbode1029@gmail.com> - 2012-01-17 03:43 -0800

csiph-web