home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #31 / NN_1992_31.iso / spool / comp / sys / mac / programm / 20162 < prev    next >
Encoding:
Internet Message Format  |  1992-12-22  |  1.2 KB

  1. Path: sparky!uunet!zaphod.mps.ohio-state.edu!pacific.mps.ohio-state.edu!linac!att!cbnewsc!cbfsb!att-out!rutgers!igor.rutgers.edu!remus.rutgers.edu!ficara
  2. From: ficara@remus.rutgers.edu (ken ficara)
  3. Newsgroups: comp.sys.mac.programmer
  4. Subject: abs(-32768) = -32768 in Th C
  5. Summary: Problem with abs function in Think C 5.0.4
  6. Keywords: Think C
  7. Message-ID: <Dec.21.20.22.18.1992.22767@remus.rutgers.edu>
  8. Date: 22 Dec 92 01:22:19 GMT
  9. Organization: Rutgers Univ., New Brunswick, N.J.
  10. Lines: 17
  11.  
  12. I'm having a problem with the library function abs in Think C 5.0.4.
  13. It's supposed to accept an int as argument. INT_MIN is defined as
  14. -32768. But when I take the abs of -32768, I get -32768 back. I
  15. realize that this is because the two's complement of 0x8000 is 0x8000
  16. with 2-byte ints. But shouldn't a function that receives an int deal
  17. with any possible in that could be passed to it? I mean, this is a
  18. classic boundary case.
  19.  
  20. Corllary: when I say "printf("%d\n",INT_MIN);" I get "-32768." But
  21. when I open up <limits.h> and look at it, it says "#define INT_MIN
  22. (~32767)". Huh?
  23.  
  24. Thanks for any help.
  25.  
  26.  
  27. Ken Ficara                                        ficara@remus.rutgers.edu
  28. GEnie: K.FICARA / Compuserve: 71311,1461 / AOL: KENFICARA / Prodigy: (Ha!)
  29.