国产av日韩一区二区三区精品,成人性爱视频在线观看,国产,欧美,日韩,一区,www.成色av久久成人,2222eeee成人天堂

Table of Contents
A brief history of integers
The Mystery of Size
Specifications brought by ANSI C (1989)
The current situation of integers
Best Practices
Home Backend Development C++ Integers in C: a little history

Integers in C: a little history

Apr 04, 2025 am 06:09 AM
c language processor ai

Integers in C: a little history

Integers are the most basic data type in programming and can be regarded as the cornerstone of programming. The job of a programmer is to give these numbers meanings. No matter how complex the software is, it ultimately comes down to integer operations, because the processor only understands integers.

To represent negative numbers, we introduced two's complement ; to represent decimal numbers, we created scientific notation, so there are floating-point numbers. But in the final analysis, everything is still inseparable from 0 and 1.


A brief history of integers

In C, int is almost the default type. Although the compiler may issue a warning, in many cases you can still write code like this:

 <code class="c">main(void) { return 0; }</code>

From a technical point of view, this is equivalent to the following code:

 <code class="c">int main(void) { return 0; }</code>

This practice stems from the programming habit at that time: if the programmer does not specify a type, it is reasonable to use integers by default.

This is also considered in the original intention of the C language design. Initially, int did not have a standard size. On the PDP-11 processor (the platform where C language was originally born), the addressing space is 16 bits, so it is reasonable int is also 16 bits. The idea at that time was that the size of int would grow with the development of the processor.

The Mystery of Size

This approach brings some problems. If the size of int varies from platform to platform, the behavior of programs compiled for different processors will vary, which is contrary to the C language "platform-independent" concept.

Unlike int , the size of char is always clearly defined: 8 bits, signed . Despite the name, char is not an abstract type of text characters, but an 8-bit integer. For example, the character "a" will be converted to the number 97 at compile time, which is simple and clear.

What about other types, such as short and long ? Its size is determined by the compiler:

 <code class="c">short // 編譯器自行決定大小long // 編譯器自行決定大小</code>

The compiler implementer is free to decide its specific size.

Specifications brought by ANSI C (1989)

The ANSI C standard sets some rules:

  • char : at least 8
  • short : at least 16 digits
  • int : at least as big as short (16-bit or 32-bit)
  • long : at least 32

This brings some specifications, but the size of int is still not clear enough. The C99 standard introduces the <stdint.h></stdint.h> header file, and the situation has improved.

Now we have fixed-size integer types:

  • int8_t : 8 bits
  • int16_t : 16 bits
  • int32_t : 32 bits
  • int64_t : 64 bit

From then on, the compiler must implement this header file using a fixed-size type.


The current situation of integers

Today, using modern compilers like GCC and Clang , the size of integers is more predictable:

type size
char 8 bits
Short 16 bits
int 32 bits
long 64 bits (32 bits on 32 bit systems)
long long 64 bits

Although long long is still a bit special, it at least brings consistency (I honestly think long long is cool).


Best Practices

Now we have header files like <stddef.h></stddef.h> and <stdint.h></stdint.h> . Use int only when necessary, such as the return type of main function. For other cases, it is best to use a fixed-size integer type in <stdint.h></stdint.h> ; for array index or loop count, use size_t in <stddef.h></stddef.h> . Hope these suggestions help you avoid some trouble.

Thank you for reading!

The above is the detailed content of Integers in C: a little history. For more information, please follow other related articles on the PHP Chinese website!

Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undress AI Tool

Undress AI Tool

Undress images for free

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

High return expectations for cryptocurrency tokens in July 2025: hype or reality? High return expectations for cryptocurrency tokens in July 2025: hype or reality? Jul 04, 2025 pm 08:42 PM

As July 2025 approaches, the crypto market is hotly discussing which tokens may bring high returns. Are names like Pi, PEPE and FloppyPepe really worth the risky investment? Potential cryptocurrencies worth paying attention to in July 2025: virtual fire or real gold? As mid-2025, the heat of discussions on high-yield crypto assets continues to heat up. Bitcoin trends and "altcoin season" expectations have attracted investors' attention. Do tokens like PiNetwork, PEPE and FloppyPepe have the potential to bring considerable investment returns? Let's analyze its prospects one by one. Altcoin Market: Can July get what it wants? Against the backdrop of Bitcoin’s expected record of historical highs, the “altcoin season” seems to be brewing. Back

What currency is bnb What is bnb? What currency is bnb What is bnb? Jul 04, 2025 pm 12:18 PM

BNB is a platform token issued by Binance and has now become a native functional token of the BNB Chain ecosystem. Its main uses include 1. Transaction fee discounts; 2. BNB Chain fuel fee; 3. Participate in the Launchpad project; 4. Payment and consumption. The recommended orders of top exchanges are: 1. Binance, providing the deepest BNB liquidity; 2. Ouyi, comprehensive product line; 3. Huobi, stable and safe operation; 4. Gate.io, rich currency selection; 5. KuCoin, many emerging projects; 6. Kraken, famous for its safety and compliance.

Binance's 25th issue of HODLer airdrop is coming, 125 million SAHARA is waiting for you to divide it up Binance's 25th issue of HODLer airdrop is coming, 125 million SAHARA is waiting for you to divide it up Jul 04, 2025 pm 06:06 PM

In today's era of rapid development of technology, the integration of artificial intelligence and blockchain is gradually becoming a new trend. The Sahara AI (SAHARA) project came into being, and it is committed to creating the first full-stack AI native blockchain platform, making the future of artificial intelligence more accessible, fair and just, and open to everyone.

Elon Musk, Sam Altman and Robinhood: A tug-of-war of tokenization? Elon Musk, Sam Altman and Robinhood: A tug-of-war of tokenization? Jul 04, 2025 pm 08:30 PM

Robinhood launched OpenAI and SpaceX tokenized stocks caused controversy, with Elon Musk and Sam Altman fighting each other over the nature of the so-called "fake equity". Recently, the intersection of Elon Musk, Sam Altman and Robinhood has become the focus of public attention, all of which stems from tokenized equity. Robinhood's launch of tokenized stocks in private companies such as OpenAI and SpaceX to European users has sparked heated debate and accompanied by clarification and criticism from all parties. Robinhood's tokenized equity: A bold attempt? Robin, led by CEO Vlad Tenev

Remittix, Monero and Cryptocurrency - The Evolution of Fiatcoin: Why has it caused heated discussion? Remittix, Monero and Cryptocurrency - The Evolution of Fiatcoin: Why has it caused heated discussion? Jul 04, 2025 pm 09:33 PM

Explore Remittix (RTX), Monero (XMR) and Crypto-Fiat Trends: How these projects shape the future of cryptocurrencies through practicality and community orientation. Remittix, Monero and Cryptocurrency Evolution: What is the hottest speculation? The crypto market is always in a dynamic change, and new and old projects are competing for investors' attention. Currently, Remittix (RTX), Monero (XMR) and crypto-fiat currency directions are becoming the focus of discussion. Let’s find out what driving forces are behind this wave of popularity? Remittix: The emerging token with emerging potential is gradually gaining market attention, and its development trajectory has been compared to the early stages of Bitcoin and Ethereum by some people. "CryptoR

Digital currency trading app Ranking of the world's most popular virtual currency platforms Digital currency trading app Ranking of the world's most popular virtual currency platforms Jul 03, 2025 am 06:30 AM

The popularity of digital currency trading platforms around the world is increasing, providing users with digital asset trading services. These platforms usually have a large user base and significant trading volume, supporting trading pairs of multiple cryptocurrencies and different trading methods, such as spot trading, contract trading, etc. They differ in terms of technical infrastructure, security measures, liquidity, and user experience. Understanding the characteristics of these platforms will help users make transaction choices that meet their needs. This article will introduce some virtual currency trading platforms that are widely popular around the world.

2025 Altcoin Ambush Guide: 10 Hundred-Time Potential Coins List Leaked 2025 Altcoin Ambush Guide: 10 Hundred-Time Potential Coins List Leaked Jul 03, 2025 am 09:12 AM

In 2025, the cryptocurrency market is like a fertile land waiting to be reclaimed, full of infinite possibilities. Every explorer is looking for the seed that can bring great rewards. This is not only about the fluctuations in digital assets, but also a deep understanding of cutting-edge technologies, community consensus and future financial paradigms. When the pulse of the global economy intertwines with the rhythm of blockchain, new opportunities will emerge quietly. What we are talking about is not the myth of getting rich overnight, but a rational and strategic layout based on a comprehensive judgment of project fundamentals, technological innovation and market sentiment.

What is Impossible Cloud Network (ICNT)? How? A comprehensive introduction to the ICN project that Binance will launch soon What is Impossible Cloud Network (ICNT)? How? A comprehensive introduction to the ICN project that Binance will launch soon Jul 07, 2025 pm 07:06 PM

Contents 1. What is ICN? 2. ICNT latest updates 3. Comparison and economic model between ICN and other DePIN projects and economic models 4. Conclusion of the next stage of the DePIN track At the end of May, ICN (ImpossibleCloudNetwork) @ICN_Protocol announced that it had received strategic investment in NGPCapital with a valuation of US$470 million. Many people's first reaction was: "Has Xiaomi invested in Web3?" Although this was not Lei Jun's direct move, the one who had bet on Xiaomi, Helium, and WorkFusion

See all articles