generated from admin/template
Удалить works/pr2/1realizacia/main.cpp
This commit is contained in:
@@ -1,25 +0,0 @@
|
||||
#include <stdio.h>
|
||||
#include <stdint.h>
|
||||
// Структура для хранения отдельных полей
|
||||
union FloatBits {
|
||||
float f;
|
||||
uint32_t bits;
|
||||
|
||||
};
|
||||
float build_float(uint32_t sign, uint32_t exp, uint32_t mantissa) {
|
||||
FloatBits u;
|
||||
u.bits = ((sign & 1u) << 31)
|
||||
| ((exp & 0xFFu) << 23)
|
||||
| (mantissa & 0x7FFFFFu);
|
||||
return u.f;
|
||||
|
||||
}
|
||||
int main() {
|
||||
float one = build_float(0, 127, 0); // 1.0
|
||||
float neg_two_five = build_float(1, 128, 0x200000); // -2.5
|
||||
float half = build_float(0, 126, 0); //0.5
|
||||
printf("1.0 = %f\n", one);
|
||||
printf("-2.5 = %f\n", neg_two_five);
|
||||
printf("0.5 = %f\n", half);
|
||||
return 0;
|
||||
}
|
||||
Reference in New Issue
Block a user