home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #20 / NN_1992_20.iso / spool / comp / lang / c / 13706 < prev    next >
Encoding:
Internet Message Format  |  1992-09-15  |  2.5 KB

  1. Xref: sparky comp.lang.c:13706 sci.math:11516 comp.lang.misc:3091 comp.lang.fortran:3577 comp.std.c:2633
  2. Path: sparky!uunet!elroy.jpl.nasa.gov!sdd.hp.com!network.ucsd.edu!mvb.saic.com!unogate!beckman.com!dn66!a_rubin
  3. Newsgroups: comp.lang.c,sci.math,comp.lang.misc,comp.lang.fortran,comp.std.c
  4. Subject: Re: Scientists as Programmers (was Re: Small Language Wanted)
  5. Message-ID: <a_rubin.716593540@dn66>
  6. From: a_rubin@dsg4.dse.beckman.com (Arthur Rubin)
  7. Date: 15 Sep 92 21:45:40 GMT
  8. Followup-To: comp.std.c
  9. References: <92Sep1.205116edt.669@neuron.ai.toronto.edu>   
  10.  <1992Sep4.162938.29237@dscomsf.desy.de> <Bu2r42.5xr@mentor.cc.purdue.edu>   
  11.  <id.I12T.GP4@ferranti.com> <a_rubin.716152347@dn66>   
  12.  <1992Sep11.012559.17662@nntpd.lkg.dec.com> <a_rubin.716225408@dn66 
  13.  <1992Sep12.164915.10734@jarvis.csri.toronto.edu> <1992Sep15.043224.27920@nntpd.lkg.dec.com>
  14. Nntp-Posting-Host: dn66.dse.beckman.com
  15. Lines: 33
  16.  
  17. In <1992Sep15.043224.27920@nntpd.lkg.dec.com> diamond@jit345.bad.jit.dec.com (Norman Diamond) writes:
  18.  
  19. >In article <1992Sep12.164915.10734@jarvis.csri.toronto.edu> flaps@dgp.toronto.edu (Alan J Rosenthal) writes:
  20. >>a_rubin@dsg4.dse.beckman.com (Arthur Rubin) writes:
  21. >>>>>>    int a, b;   long c;
  22. >>>My interpretation (from reading K&R 2) would be that c = a * b should be
  23. >>>equivalent to c = (int)(a * b).
  24.  
  25. >Mr. Rubin, please state which section of the standard requires this.
  26. >If you cannot, then please at least quote the text in K&R 2 that led you to
  27. >this interpretation, so that we can see if K&R 2 has a bug that would be
  28. >worth recommending for correction and/or warning about.
  29.  
  30. My copy of K&R 2 has walked away.  K&R 1, in the section on type
  31. conversions (2.7), states:
  32.  
  33.     Implicit arithmetic conversions work much as expected.  In general, if
  34.     an operator like + or * which takes two operands (a "binary operator")
  35.     has operands of different types, the "lower" type is _promoted_ to the
  36.     "higher" type before the operations proceeds.  The result is of the
  37.     higher type....
  38.  
  39. I don't recall exactly what the analogous section of K&R 2 states, but I
  40. recall that last sentence being there.  This implies that the result in
  41. case of overflow, although undefined, is an undefined int.
  42.  
  43. Followups to comp.std.c, as it no longer is relevant to any of the other
  44. groups.
  45. --
  46. Arthur L. Rubin: a_rubin@dsg4.dse.beckman.com (work) Beckman Instruments/Brea
  47. 216-5888@mcimail.com 70707.453@compuserve.com arthur@pnet01.cts.com (personal)
  48. My opinions are my own, and do not represent those of my employer.
  49. My interaction with our news system is unstable; please mail anything important.
  50.