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


Groups > comp.lang.c > #70944

Re: What is truncation for (singed) integer in C ?

From James Kuyper <jameskuyper@verizon.net>
Newsgroups comp.lang.c
Subject Re: What is truncation for (singed) integer in C ?
Date 2015-09-19 16:52 -0400
Organization Self
Message-ID <55FDCB19.7070401@verizon.net> (permalink)
References <6f66f235-1b11-4b0c-b2d8-c49ac3eac78e@googlegroups.com> <87twqq9msk.fsf@bsb.me.uk> <d65vdmFsqvaU1@mid.individual.net>

Show all headers | View raw


On 09/19/2015 04:38 PM, Tim Prince wrote:
...
> My references imply that the definition with truncation towards 0 came
> in with C89.  Before that, i/2 might be considered interchangeable with
> i>>1 regardless of whether 1's or 2's complement was in use, even though
> they give different results.

Not quite. The change was made in C99, not C89. In C89, it was
unspecified whether fractions were rounded toward zero or toward
-infinity. I'm not sure whether it was implementation-defined, but I
think it was. There was no requirement that i/2 be the same as i>>1.

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


Thread

What is truncation for (singed) integer in C ? fl <rxjwg98@gmail.com> - 2015-09-19 12:25 -0700
  Re: What is truncation for (singed) integer in C ? fir <profesor.fir@gmail.com> - 2015-09-19 12:55 -0700
    Re: What is truncation for (singed) integer in C ? fir <profesor.fir@gmail.com> - 2015-09-19 13:20 -0700
  Re: What is truncation for (singed) integer in C ? Geoff <geoff@invalid.invalid> - 2015-09-19 13:05 -0700
  Re: What is truncation for (singed) integer in C ? Ben Bacarisse <ben.usenet@bsb.me.uk> - 2015-09-19 21:28 +0100
    Re: What is truncation for (singed) integer in C ? Tim Prince <tprince@computer.org> - 2015-09-19 16:38 -0400
      Re: What is truncation for (singed) integer in C ? James Kuyper <jameskuyper@verizon.net> - 2015-09-19 16:52 -0400
  Re: What is truncation for (singed) integer in C ? Keith Thompson <kst-u@mib.org> - 2015-09-19 13:45 -0700
  Re: What is truncation for (singed) integer in C ? James Kuyper <jameskuyper@verizon.net> - 2015-09-19 16:46 -0400
  Re: What is truncation for (singed) integer in C ? Eric Sosman <esosman@comcast-dot-net.invalid> - 2015-09-19 16:47 -0400
  Re: What is truncation for (singed) integer in C ? Joe Pfeiffer <pfeiffer@cs.nmsu.edu> - 2015-09-19 22:55 -0600
  Re: What is truncation for (singed) integer in C ? James Kuyper <jameskuyper@verizon.net> - 2015-09-20 10:54 -0400
    Re: What is truncation for (singed) integer in C ? Joe Pfeiffer <pfeiffer@cs.nmsu.edu> - 2015-09-20 10:11 -0600

csiph-web