跪求利用共用体编写的C51单片机C语言程序例子,最好有祥细的程序讲解。谢了。

来源:百度知道 编辑:UC知道 时间:2024/06/08 02:17:03
对于一楼这个吊毛我是相当的无语的,好好的你跑来添什么乱,你有问题啊?

//共用体其实有时也会用到,特别是RAM不够的时候,我们可以定义一个union,一会把它当做这种类型的变量用,一会又作另外的变量用,当然要前面一个变量不用才能当另外类型变量用,
As an alternative, you may use the following union to store floating-point values.

union f {
float f; /* Floating-point value */
unsigned long ul; /* Unsigned long value */
};

This union contains a float and an unsigned long in order to perform floating-point math operations and to respond to the IEEE error states.

For example:

#define NaN 0xFFFFFFFF /* Not a number (error) */
#define plusINF 0x7F800000 /* Positive overflow */
#define minusINF 0xFF800000 /* Negative overflow */

union f {
float f; /* Floating-point value */
unsigned long ul; /* Unsigned long value */
};

void main (void) {
float a, b;
union f x;

x.f = a * b;
if (x.ul == NaN || x.ul == plusINF |