MIPI_AdvancedC_FRTK/Lect1/12_page_20.c
2024-11-14 08:45:50 +03:00

22 lines
334 B
C

#include <stdio.h>
#include <inttypes.h>
void changeSign(float *f) {
union {
float f;
uint32_t u;
} tmp;
tmp.f = *f;
tmp.u = tmp.u ^ 0x80000000;//1000 0000 0000 0000 0000 0000 0000 0000
*f = tmp.f;
}
int main(void)
{
float f = 4.0;
changeSign(&f);
printf("%f\n",f);
return 0;
}