Re: [Dev-C++] Can I handle 64 bits with unsigned long long int ?
Open Source C & C++ IDE for Windows
Brought to you by:
claplace
|
From: Roberto R. <rob...@ar...> - 2003-04-12 03:25:04
|
Hi all,
Sorry was not here by the while. IM learn about C & C++ standares just
here, at dev-cpp list. Im not a expert programmer, using I64 I can
handle 64 bits hexa friendly. I use it to work with comunications
protocols, industrial controls, etc.
....
scanf ("%I64x",&Dato);
gotoxy(1,11);printf ("Dec0: %I64u\nDec1: %I64u\n\n", Dato, Dato1);
....
Will try to ask some friends about C99 books :)
Thanks Ioannis
Roberto
Ioannis Vranos wrote:
>Question about C99. That is a first! See below:
>
>
>
>
>
>>-----Original Message-----
>>From: dev...@li...
>>[mailto:dev...@li...] On Behalf
>>Of Roberto Ricardi
>>Sent: Sunday, April 06, 2003 2:11 AM
>>To: 'Dev-C++ -Users-List'
>>Subject: [Dev-C++] Can I handle 64 bits with unsigned long long int ?
>>
>>
>>Hi all,
>>
>>Can I handle 64 bits numbers with unsigned long long ?
>>
>>#include <stdio.h>
>>#include <stdlib.h>
>>#include <conio.h>
>>
>>unsigned long long int D0,D1 ;
>>
>>int main(int argc, char *argv[])
>>{
>> D0 = 0;
>> D1 = 0xffffffffffff; /* I put first unsigned long int, compiler
>>alerts about truncated number...) */
>> gotoxy(1,9);printf ("Num hexa : ");
>> scanf ("%x",&D0); /*can handle whatever up to 32 bits*/
>> gotoxy(1,11);printf ("Dec0: %lu\nDec1: %lu\n\n", D0, D1);
>>
>> getchar(); getchar();
>> return 0;
>>}
>>/*
>>Results:
>>
>>Dec0 : 4294967295 mean ok if I put just up to 0xffffffff 32bits
>>Dec1 : 0 ??
>>*/
>>
>>Why is ever truncated in 32 bits, how can handle long long to
>>get up to
>>64 bits numbers ?
>>
>>
>
>
>unsigned long long is not guaranteed to be 64-bit. If you want an unsigned
>integral type to be at least 64-bit, you have to do:
>
>
>#include <stdint.h>
>
>// ...
>
>uint_least64_t D0, D1;
>
> // ...
>
>
>
>which is a typedef of the closest to 64-bit type provided by platform
>(closest from above, that is if unsigned long is 32 bit and unsigned long
>long is 128 bit for example, the typedef will be of unsigned long long).
>
>
>I read it straight from the standard. I do not know whether MINGW has
>implemented it (and as far as I know these facilities are "optional", if the
>platform doesn't support >=64 bit, will not have the above type naturally).
>
>
>By the way, have you got any book regarding C99? If yes, can you please tell
>me which?
>
>
>
>
>Ioannis Vranos
>
>* Programming pages: http://www.noicys.freeurl.com
>* Alternative URL: http://run.to/noicys
>
>
>Anti-racism movement: http://www.positive-youthfoundation.org
>Iraq Peace Pledge: http://www.peacepledge.org
>
>
>
>
>-------------------------------------------------------
>This SF.net email is sponsored by: ValueWeb:
>Dedicated Hosting for just $79/mo with 500 GB of bandwidth!
>No other company gives more support or power for your dedicated server
>http://click.atdmt.com/AFF/go/sdnxxaff00300020aff/direct/01/
>_______________________________________________
>Dev-cpp-users mailing list
>Dev...@li...
>TO UNSUBSCRIBE: http://www.noicys.cjb.net/devcpp/ub.htm
>https://lists.sourceforge.net/lists/listinfo/dev-cpp-users
>
>
>
|