home *** CD-ROM | disk | FTP | other *** search
- 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
- From: ficara@remus.rutgers.edu (ken ficara)
- Newsgroups: comp.sys.mac.programmer
- Subject: abs(-32768) = -32768 in Th C
- Summary: Problem with abs function in Think C 5.0.4
- Keywords: Think C
- Message-ID: <Dec.21.20.22.18.1992.22767@remus.rutgers.edu>
- Date: 22 Dec 92 01:22:19 GMT
- Organization: Rutgers Univ., New Brunswick, N.J.
- Lines: 17
-
- I'm having a problem with the library function abs in Think C 5.0.4.
- It's supposed to accept an int as argument. INT_MIN is defined as
- -32768. But when I take the abs of -32768, I get -32768 back. I
- realize that this is because the two's complement of 0x8000 is 0x8000
- with 2-byte ints. But shouldn't a function that receives an int deal
- with any possible in that could be passed to it? I mean, this is a
- classic boundary case.
-
- Corllary: when I say "printf("%d\n",INT_MIN);" I get "-32768." But
- when I open up <limits.h> and look at it, it says "#define INT_MIN
- (~32767)". Huh?
-
- Thanks for any help.
-
-
- Ken Ficara ficara@remus.rutgers.edu
- GEnie: K.FICARA / Compuserve: 71311,1461 / AOL: KENFICARA / Prodigy: (Ha!)
-