| delorie.com/archives/browse.cgi | search |
| From: | your AT name DOT here (Kirk Hobart) |
| Newsgroups: | comp.os.msdos.djgpp |
| Subject: | Re: LARGE numbers. |
| Date: | Thu, 27 Aug 1998 09:36:34 GMT |
| Organization: | Airnews.net! at Internet America |
| Lines: | 29 |
| Message-ID: | <BF7C9431B1C4A4F2.1C2046D82A229260.4EE6E1A4D51E92D1@library-proxy.airnews.net> |
| References: | <1103_904198596 AT isaacc> |
| Abuse-Reports-To: | abuse at airmail.net to report improper postings |
| NNTP-Proxy-Relay: | librarytest.airnews.net |
| NNTP-Posting-Time: | Thu Aug 27 04:36:37 1998 |
| NNTP-Posting-Host: | cUZ2!+CQrX1GLmH0d%T0Be1BFCh,,>Bl.F%+TMKB (Encoded at Airnews!) |
| 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;
>
>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!
#include <stdio.h>
int main(void)
{
double a = 25834242042.0;
float b = 25834242042.0;
long long c = 25834242042;
printf(" double: %.1f\n", a);
printf(" float: %.1f\n", b);
printf("long long: %Ld\n", c);
return 0;
}
Compile with djgpp and run...
double: 25834242042.0
float: 25834242048.0
long long: 25834242042
Notice the round-off error in the float.
| webmaster | delorie software privacy |
| Copyright © 2019 by DJ Delorie | Updated Jul 2019 |