delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1997/07/30/10:04:25

From: schweikh AT rubin DOT noc DOT dfn DOT de (Jens Schweikhardt)
Newsgroups: comp.lang.c,comp.os.msdos.djgpp
Subject: Re: having trouble with long numbers
Date: 30 Jul 1997 07:03:31 GMT
Organization: Regional Network of Baden-Wuerttemberg, Stuttgart, FRG
Lines: 32
Message-ID: <5rmp03$58l$1@news.belwue.de>
References: <01bc9c51$0ceeec80$78ed1fcc AT darkstar> <33DE6FA3 DOT 460B59E AT voyager DOT net>
NNTP-Posting-Host: rubin.noc.dfn.de
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp

In article <33DE6FA3 DOT 460B59E AT voyager DOT net> Mark Levis <mlevis AT voyager DOT net> writes:
# Michèle C. Dupré wrote:
# >>I want to be able to have more than 10 digits print out (if the age were
# >>10,000 years for example).
# >>I am new to C (and programming in general) and teaching myself, so any
# >>criticism will be appreciated.
# 
# Use a double. It will have precision up to 14 digits.

Nope. The Standard guarantees only a number of 10 significant digits
minimum.  The actual limit on your system is available with DBL_DIG
from <float.h>.  If DBL_DIG is too small, you could try long double
with LDBL_DIG digits.  However, LDBL_DIG is only guaranteed to be at
least 10 as well.

# An int will only handle number from -32767 to 32768.

Nope. An int will handle at least any number from -32767 to 32767. It
might be able to hold 32, 42 or 64 bit.  (Note that on many 16bit 2s
complement machines your sign needs to be reversed:  INT_MIN from
<limits.h> may be -32768 and INT_MAX may be 32767).

# unsigned int 0 65535
 
Dito. These are minimum values only. See UINT_MAX from <limits.h>.

Regards,

	Jens
--
Jens Schweikhardt  http://www.uni-stuttgart.de/People/schweikhardt/home.html
SIGSIG -- signature too long (core dumped)

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019