请问这个要怎么解决?在//REPLACE ME WITH YOUR CODE那写内容,在float_exp.c上写内容,按照要求来写,要写main函数,就像最下面的图片的例子那样。在可以用下面的例子来测试是否正确。原题为英文,有机翻。da佬编写1下,蟹蟹大lao。题目如下
float_exp.c内容
#include "float_exp.h"
// given the 32 bits of a float return the exponent
uint32_t float_exp(uint32_t f) {
return 42; // REPLACE ME WITH YOUR CODE
}
float_exp.h内容
#include <stdio.h>
#include <stdint.h>
#include <stdlib.h>
#ifndef FLOAT_EXP_H
#define FLOAT_EXP_H
#include <assert.h>
/// We use `union overlay' to obtain the raw bits of a `float'-type
/// value, by storing the `float' in the `f' field and then using the
/// `u' field to obtain the bits.
union overlay {
float f;
uint32_t u;
};
uint32_t float_exp(uint32_t f);
#endif
#include <stdio.h>
#include <stdint.h>
uint32_t float_exp(uint32_t f)
{
f = f<<1;
f = f>>24;
return f;
}
union overlay {
float f;
uint32_t u;
};
int main()
{
overlay lay;
lay.f = -42;
printf("0x%x\n",float_exp(lay.u));
lay.f = 3.14159012;
printf("0x%x\n",float_exp(lay.u));
return 0;
}