Home >Backend Development >C#.Net Tutorial >What does lld mean in c language?

What does lld mean in c language?

下次还敢
下次还敢Original
2024-05-07 08:09:19973browse

In C language, lld represents a 64-bit signed integer, that is, long long decimal. Specifically: the int type is a 32-bit integer, ranging from -2^31 to 2^31-1. The long long type is a 64-bit integer, ranging from -2^63 to 2^63-1. A long long type variable can be declared by adding the ll suffix after the variable name. Commonly used functions include: %lld: formatted input/output. atoi: Convert string to int, use atoll to convert to long long. When using the long long type, you need to pay attention to its 64-bit attributes and use the corresponding functions to handle it.

What does lld mean in c language?

The meaning of lld in c language

In C language, lld is# Abbreviation of ##long long decimal, used to represent a 64-bit signed integer.

Detailed explanation

In C language, the integer types are

int (32 bits) and long long (64 Bit). The int type can represent integers in the range -2^31 to 2^31-1, while the long long type can represent the range It is an integer from -2^63 to 2^63-1.

When you need to represent an integer beyond the range of

int, you can use the long long type. When declaring a long long variable, you need to add the ll suffix after the variable name, for example:

<code class="c">long long my_number;</code>
is using the

long long type When a variable is used, it can be used as an ordinary integer, but it should be noted that it is a 64-bit integer and needs to be processed using appropriate functions and macros.

The following are some common functions related to the

long long type:

  • %lld: used for printfFormat input and output data of long long type in # and scanf.
  • atoi(const char *str): Convert a string to type int. If you need to convert to long long type, you need to use the atoll(const char *str) function.
  • atoll(const char *str): Convert a string to long long type.

Example

<code class="c">#include <stdio.h>

int main() {
    long long my_number;

    printf("请输入一个数字:");
    scanf("%lld", &my_number);

    printf("您输入的数字是:%lld\n", my_number);

    return 0;
}</code>
In this example, we declare a variable of type

long longmy_number . We then use the scanf function to get a number from the user input and store it in my_number. Finally, we use the printf function to output the value of my_number.

The above is the detailed content of What does lld mean in c language?. For more information, please follow other related articles on the PHP Chinese website!

Statement:
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