[C language]Handling 64-bit integers

Last update on October 3, 2009 07:56 AM by jak58
Published by netty5

[C language]Handling 64-bit integers






Basically in C language, an unsigned number over 32 bit can not exceed the value of 4 294 967 295.
It may happen that you are required to handle higher numbers and for this you need these numbers to be coded in 64 bit.

However, this may not be handled in the same way as an ordinary integer. The constants and the posting of these numbers must be defined differently.

Unsigned 64-bit integer


Type: unsigned long long
Formatting for display: % llu
Suffix to define a constant: ULL

Example:


//Assign the value in a 4294967296 
unsigned long long a= 4294967296ULL; 
//Show the value 
printf ( "% llu", a);

Signed 64-bit integer


Type: long long
Formatting for display: % lld
Suffix to define a constant: LL

Example:


//Assign the value in a 4294967296 
long long a= 4294967296LL; 
// Show the value 
printf ( "% lld", a); 



Using an unusual suffix to define a constant value

Unsigned long long a = 4294967296

Your compiler will prompt you that this number is too large for "long" typr. Ie a full 32 bits. The constants have such default. This concept is directly related to the architecture of 32-bit processors. A record 32-bit processor is limited and your default compiler will try to fit the numbers in one registry. But with a suffix such as LL and ULL, your compiler will store your number on 2 registers, i.e. on 64-bit, hence providing an optimized use.
Best answers for « Handling 64 bit integers » in :
Converting a 32-bit integer into IP Show Converting a 32-bit integer into IP Number to convert: 3265917058 Binary representation 11000010 10101001 11110000 10000010 - 3265917058 00000000 00000000 00000000 11000010 - 3265917058 >> 24 ( 194 ) 11000010 10101001 11110000...
Adobe Flash Player on Vista 64-bit Show Adobe Flash Player on Vista 64-bit Issue Solution Issue As you know, there’s any version of flash player available for Vista 64-bit platform. So you will not be able to watch streaming videos or access some websites. I guess you...
Compiling an assembly program with Nasm ShowCompiling an assembly program with Nasm Intro With LInux With Windows Intro Netwide Assembler (NASM) is an assembler and disassembler for the Intel x86 architecture and is commonly used to create 16-bit, 32-bit (IA-32) and 64-bit...
Compiling/testing in 32-bit on Ubuntu X86-64 ShowCompiling/testing in 32-bit on Ubuntu X86-64 If you want compile a source code for testing purpose or to use it as a 32-bit binary,the main problem is that the headers of the standard library are not suitable for this purpose and that a...
How to use a driver ODBC 32 BITS under the Window 2003(64 bits)? ShowHow to use a driver ODBC 32 BITS under the Window 2003(64 bits)? You have a Windows 2003 server (64-bits) and you want to use a 32 bits ODBC driver: one that is usually found in the administrative panel for ODBC on Windows or an external...
Download Rhinoback x64 ShowRhinoback x64 is a secure service and reliable designed for 64-bit operating systems Windows 2003, XP, Vista. The program offers an incremental backup, file encryption and support for Exchange Server, SQL Server, MySQL. Advantage The data is...
Download VLC ShowDescription: VLC media player is a portable multimedia player for many video and audio formats (MPEG1, MPEG2, MPEG4, DivX, mp3, ogg, ...) as well as DVDs, VCDs, and various streaming protocols. This program can also be used as a server to stream in...
Representation of real numbers and integers ShowRepresenting a number in a computer Representing (or encoding) a number means to express it in binary form. Representing numbers in a computer is necessary in order for it to be able to store and manipulate them. However, the problem is that a...
Random access memory (RAM or PC memory) ShowTypes of random access memory There are generally two broad categories of random access memory: DRAM memories (Dynamic Random Access Module), which are inexpensive. They are used essentially for the computer's main memory SRAM memories (Static...
PCI Bus ShowThe PCI Bus The PCI bus (Peripheral Component Interconnect) was developed by Intel on 22 June 1992. Contrary to the VLB bus, it is not so much a traditional local bus but rather an intermediate bus located between the processor bus (NorthBridge)...