摘要: c语言中显示各种数据类型的大小。 #include <stdio.h> int main(void) { //char type printf("char: %zd.\n\n", sizeof(char)); //integer type printf("short: %zd.\n", sizeof 阅读全文
posted @ 2021-07-20 22:56 小鲨鱼2018 阅读(303) 评论(0) 推荐(0) 编辑
摘要: c语言中浮点数的舍入错误。 1、 #include <stdio.h> int main(void) { float a, b; b = 2.0e20 + 1.0; a = b - 2.0e20; float c, d; d = 2.0e5 + 1.0; c = d - 2.0e5; printf( 阅读全文
posted @ 2021-07-20 22:06 小鲨鱼2018 阅读(179) 评论(0) 推荐(0) 编辑
摘要: 1、c语言中浮点值的上溢 #include <stdio.h> int main(void) { float test1 = 5.2e4 * 100.0f; float test2 = 5.2e40 * 100.0f; //超出float类型可以表示的范围。 printf("test1: %e.\n 阅读全文
posted @ 2021-07-20 22:00 小鲨鱼2018 阅读(314) 评论(0) 推荐(0) 编辑