www.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1998/08/27/18:50:47

From: Endlisnis <s257m AT unb DOT ca>
Newsgroups: comp.os.msdos.djgpp
Subject: Re: LARGE numbers.
Date: Thu, 27 Aug 1998 11:22:35 -0300
Organization: NBTel Internet
Lines: 47
Message-ID: <35E56BAA.424BE1B3@unb.ca>
References: <1103_904198596 AT isaacc>
NNTP-Posting-Host: fctnts11c20.nbnet.nb.ca
Mime-Version: 1.0
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp

isaacc AT flash DOT net wrote:

> I want to store the following number (25834242042) as an int, I declare it as usual:
> int var = 258342042;

    Did you notice that the numbers you wrote were different?  I'll assume that you meant the larger,
first one.

> yet the number is obviouslu too large to store as an integer (even an unsigned one).
> Subsequently I try to store it as both 'float' and 'double' - yet they wont even hold a number of
> this size!
> What can I do to get a larger varable declaration???

That number will fit into a double.  But, a 'long long' is probably what you want.  Here is a program
that shows that the number will fit into a double.

#include <iostream.h>

int main()
{
 int Int = 25834242042;
 float Float = 25834242042;
 double Double = 25834242042;
 long long Long = 25834242042;
 cout.precision(15);
 cout << Int << endl
      << Float << endl
      << Double << endl
      << Long << endl;
 }

===Output===
64438266
25834242048
25834242042
25834242042


--
     (\/) Endlisnis (\/)
          s257m AT unb DOT ca
          Endlisnis AT GeoCities DOT com
          Endlis AT nbnet DOT nb DOT ca




- Raw text -


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