课时51printf使用小结
从小到大,记忆方式,先记住int
类型 十进制 八进制 十六进制
char %hhd %hho %hhx
unsigned char %hhu %hho %hhx
short %hd %ho %hx
unsigned short %hu %ho %hx
int %d %o %x
unsigned int %u %o %x
long %ld %lo %lx
unsigned long %lu %lo %lx
long long %lld %llo %llx
unsigned long long %llu %llo %llx
课时55关系运算符
比较两个浮点数的大小,不能简单地使用大于小于,需要一个EPSILON
#include <stdio.h> #include <stdlib.h> #include <math.h> #define EPSILON 0.00000001 int main() { double double_data_src = 0.11; double double_data_dst = 0.109999994; if (fabs(double_data_src - double_data_dst) <= EPSILON) { printf("equal "); } else { printf("not equal "); } system("pause"); return 0; }