Mail Archives: djgpp/2005/11/18/16:16:59
X-Authentication-Warning: | delorie.com: mail set sender to djgpp-bounces using -f
|
Date: | Fri, 18 Nov 2005 16:15:08 -0500
|
Message-Id: | <200511182115.jAILF8Gt007059@delorie.com>
|
From: | Martin Ambuhl <mambuhl AT earthlink DOT net>
|
User-Agent: | Mozilla Thunderbird 1.0.6 (Windows/20050716)
|
X-Accept-Language: | en-us, en
|
MIME-Version: | 1.0
|
Newsgroups: | comp.os.msdos.djgpp
|
Subject: | Re: printf() doesn't print long long intege, maybe RHIDE problem
|
To: | djgpp AT delorie DOT com
|
DJ-Gateway: | from newsgroup comp.os.msdos.djgpp
|
Reply-To: | djgpp AT delorie DOT com
|
References: <437d9a13 AT news DOT bezeqint DOT net>
In-Reply-To: <437d9a13 AT news DOT bezeqint DOT net>
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 7bit
Lines: 64
Message-ID: <9krff.1763$wf DOT 538 AT newsread3 DOT news DOT atl DOT earthlink DOT net>
Date: Fri, 18 Nov 2005 21:03:01 GMT
NNTP-Posting-Host: 165.247.25.111
X-Complaints-To: abuse AT earthlink DOT net
X-Trace: newsread3.news.atl.earthlink.net 1132347781 165.247.25.111 (Fri, 18 Nov 2005 13:03:01 PST)
NNTP-Posting-Date: Fri, 18 Nov 2005 13:03:01 PST
Organization: EarthLink Inc. -- http://www.EarthLink.net
Xref: news.mv.net comp.os.msdos.djgpp:127961
greenberg moshe wrote:
> Hi
> printf() do not print long long integer.
> It look like RHIDE problem because the size check of the number is ok.
> Moshe
>
>
Show us how it fails. Here is an example of it working:
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
#include <string.h>
int main(void)
{
long long xll;
size_t i, j, ndx, n = sizeof(long long) / sizeof(int);
int x[n];
char c[sizeof(long long)];
if (sizeof(long long) % sizeof(int)) {
printf
("This example requires sizeof(long long) to be\n"
" a multiple of sizeof(int)\n");
exit(EXIT_FAILURE);
}
srand(time(0));
for (i = 0; i < 5; i++) {
for (ndx = 0, j = 0; j < n; j++, ndx += sizeof(int)) {
x[j] = rand();
memcpy(c + ndx, x + j, sizeof(int));
}
memcpy(&xll, c, sizeof(long long));
printf("Here is a long long: %lld (decimal) %#llx (hex)\n"
"made from these ints (as hex):\n",
xll, (unsigned long long) xll);
for (j = 0; j < n; j++)
printf("%#x ", (unsigned) x[j]);
printf("\n\n");
}
return 0;
}
Here is a long long: 5983791420887767295 (decimal) 0x530ab298040b98ff (hex)
made from these ints (as hex):
0x40b98ff 0x530ab298
Here is a long long: 9081887572752223580 (decimal) 0x7e0958a127ee4d5c (hex)
made from these ints (as hex):
0x27ee4d5c 0x7e0958a1
Here is a long long: 199024756084199939 (decimal) 0x2c313f60fe85203 (hex)
made from these ints (as hex):
0xfe85203 0x2c313f6
Here is a long long: 7037913556498271489 (decimal) 0x61abb11756fc4d01 (hex)
made from these ints (as hex):
0x56fc4d01 0x61abb117
Here is a long long: 1917151184894115895 (decimal) 0x1a9b16d85c554037 (hex)
made from these ints (as hex):
0x5c554037 0x1a9b16d8
- Raw text -