gpt4 book ai didi

C输出不打印溢出

转载 作者:太空宇宙 更新时间:2023-11-04 08:13:16 25 4
gpt4 key购买 nike

<分区>

我想了解为什么输出显示 unsigned short 溢出而不是 unsigned long?举个例子?

#include <stdio.h>
#include <stdlib.h>

unsigned short us(float s);
unsigned long ul(float l);
float a = -10;
int main()
{
printf("us method return: %d ", us(a));
printf("\nul method return: %d ", ul(a));
return 0;
}

unsigned short us(float s)
{
return (s + 1);
}
unsigned long ul(float l)
{
return (l + 1);
}

输出是:

us method return: 65527 
ul method return: -9

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