delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/2002/03/14/08:15:09

X-Authentication-Warning: delorie.com: mailnull set sender to djgpp-bounces using -f
From: "A. Sinan Unur" <asu1 AT cornell DOT edu>
Newsgroups: comp.os.msdos.djgpp
Subject: Re: Newbie Division Operator Question
Date: 14 Mar 2002 13:14:17 GMT
Organization: Cornell University
Lines: 46
Sender: asu1 AT cornell DOT invalid (on pool-141-149-206-253.syr.east.verizon.net)
Message-ID: <Xns91D153C891F9Basu1cornelledu@132.236.56.8>
References: <d26d20a2 DOT 0203140257 DOT 6365ae0e AT posting DOT google DOT com>
NNTP-Posting-Host: pool-141-149-206-253.syr.east.verizon.net
X-Trace: news01.cit.cornell.edu 1016111657 26293 141.149.206.253 (14 Mar 2002 13:14:17 GMT)
X-Complaints-To: usenet AT news01 DOT cit DOT cornell DOT edu
NNTP-Posting-Date: 14 Mar 2002 13:14:17 GMT
User-Agent: Xnews/L5
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp
Reply-To: djgpp AT delorie DOT com

zandro_arceo AT support DOT trendmicro DOT com (IeperNaum) wrote in 
news:d26d20a2 DOT 0203140257 DOT 6365ae0e AT posting DOT google DOT com:

> #define __int64 long long
> 
> unsigned __int64 x = 268486768;
> 
> unsigned __int64 y = x/10000000;
> 
> i expect y = 26 
> but y = 4065811060.
> 
> can anybody please explain to me why?

it is either the #define rather than typedef getting in your way, or you 
are not specifying the conversion specifier in printf correctly.

read the printf docs by invoking info in the following way:

info libc alpha printf

C:\develop\src\misc>cat d.c
#include <stdio.h>

typedef unsigned long long myuint64;

static void doit(void)
{
        myuint64 x = 268486768;
        myuint64 y = x/10000000;

        printf("y = %llu\n", y);

        return;
}

int main(void)
{
        doit();
        return 0;
}

C:\develop\src\misc>gcc -Wall d.c -o d.exe

C:\develop\src\misc>d
y = 26

- Raw text -


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