| ftp.delorie.com/archives/browse.cgi | search |
| X-Authentication-Warning: | delorie.com: mail set sender to djgpp-bounces using -f |
| From: | Martin Ambuhl <mambuhl AT earthlink DOT net> |
| User-Agent: | Mozilla Thunderbird 0.9 (Windows/20041103) |
| X-Accept-Language: | en-us, en |
| MIME-Version: | 1.0 |
| Newsgroups: | comp.os.msdos.djgpp |
| Subject: | Re: long long |
| References: | <140 DOT 3ef15c87 DOT 2f500941 AT aol DOT com> |
| In-Reply-To: | <140.3ef15c87.2f500941@aol.com> |
| Lines: | 105 |
| Message-ID: | <oVITd.6802$Ba3.5719@newsread2.news.atl.earthlink.net> |
| Date: | Fri, 25 Feb 2005 17:05:24 GMT |
| NNTP-Posting-Host: | 165.247.42.254 |
| X-Complaints-To: | abuse AT earthlink DOT net |
| X-Trace: | newsread2.news.atl.earthlink.net 1109351124 165.247.42.254 (Fri, 25 Feb 2005 09:05:24 PST) |
| NNTP-Posting-Date: | Fri, 25 Feb 2005 09:05:24 PST |
| Organization: | EarthLink Inc. -- http://www.EarthLink.net |
| To: | djgpp AT delorie DOT com |
| DJ-Gateway: | from newsgroup comp.os.msdos.djgpp |
| Reply-To: | djgpp AT delorie DOT com |
Sterten AT aol DOT com wrote:
>>DJGPP already supports 64-bit variables: there's the `long long' data
>>type which is 64-bit wide.
>
>
>
> very good ! Thanks. I didn't know that. Probably because it's different
> in other compilers so when someone sends me a program which uses 64-bit
> then I can't compile it.
>
> #define int long long
> //#define %i %Li , this doesn't work
> int i,j;
> main(){
> i=13267364410352;
> m1:printf("short:%i long:%Li\n",i,i); //this doesn't work. Why ?
> printf("short:%i ",i);printf("long:%Li\n",i); //this works
> if(i%2==0){i=i/2;goto m1;}
> }
>
/* If you *must* use the same code with multiple types, don't do it by
#defining built-in types to have some other meaning. Also, use the
correct specifiers ('%Li' is always incorrect). Notice the way I
have introduced the substitutable format with the define. */
#include <stdio.h>
typedef long long INTEGER;
#define INTEGER_FORMAT "%lld"
int main(void)
{
INTEGER i = 4611686018427387903ll;
do {
printf("long:" INTEGER_FORMAT "\n", i);
i /= 2;
} while (i % 2);
return 0;
}
[output]
long:4611686018427387903
long:2305843009213693951
long:1152921504606846975
long:576460752303423487
long:288230376151711743
long:144115188075855871
long:72057594037927935
long:36028797018963967
long:18014398509481983
long:9007199254740991
long:4503599627370495
long:2251799813685247
long:1125899906842623
long:562949953421311
long:281474976710655
long:140737488355327
long:70368744177663
long:35184372088831
long:17592186044415
long:8796093022207
long:4398046511103
long:2199023255551
long:1099511627775
long:549755813887
long:274877906943
long:137438953471
long:68719476735
long:34359738367
long:17179869183
long:8589934591
long:4294967295
long:2147483647
long:1073741823
long:536870911
long:268435455
long:134217727
long:67108863
long:33554431
long:16777215
long:8388607
long:4194303
long:2097151
long:1048575
long:524287
long:262143
long:131071
long:65535
long:32767
long:16383
long:8191
long:4095
long:2047
long:1023
long:511
long:255
long:127
long:63
long:31
long:15
long:7
long:3
long:1
| webmaster | delorie software privacy |
| Copyright © 2019 by DJ Delorie | Updated Jul 2019 |