且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

在C中将float转换为int(按位)

更新时间:2022-04-03 22:32:03

C 有联合"来处理这种类型的数据视图:

C has the "union" to handle this type of view of data:

typedef union {
  int i;
  float f;
 } u;
 u u1;
 u1.f = 45.6789;
 /* now u1.i refers to the int version of the float */
 printf("%d",u1.i);