gpt4 book ai didi

C++ 后缀 L 与指定 long double

转载 作者:行者123 更新时间:2023-11-27 23:49:25 25 4
gpt4 key购买 nike

问题 What does the "L" mean at the end of an integer literal?在 int 文字的末尾描述 L 的含义。我很困惑为什么不指定 long int i = 33 而不是 int i = 33L?同样的事情也适用于其他类型。为什么不指定 double b = 3.0L 而不是写 long double

最佳答案

I am confused why not to specify long int i = 33 instead of int i = 33L?

因为这 2 个陈述意味着 2 个不同的事物:

long int i = 33; // take constant of type int, convert it to long int and assign to i.

int i = 33L; // take constant of type long int, convert it to int and assign to i.

所以你最终得到了不同类型的变量 i。与您的示例中的 double 相同。

关于C++ 后缀 L 与指定 long double,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47678631/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com