Обновить lab2/README.md
This commit is contained in:
@@ -10,35 +10,3 @@
|
|||||||
|
|
||||||
# Ход работы:
|
# Ход работы:
|
||||||
|
|
||||||
*Задание 1*
|
|
||||||
Основнвой код:
|
|
||||||
```C
|
|
||||||
#include <stdio.h>
|
|
||||||
#include <stdint.h>
|
|
||||||
#include <string.h>
|
|
||||||
|
|
||||||
union FloatCvrt{
|
|
||||||
uint32_t raw_bits;
|
|
||||||
float value;
|
|
||||||
};
|
|
||||||
|
|
||||||
float makeFloat(uint32_t sign, uint8_t exp, uint32_t mantissa){
|
|
||||||
union FloatCvrt converter;
|
|
||||||
|
|
||||||
converter.raw_bits = ((sign & 0x1) << 31) | (((uint32_t)exp & 0xFF) << 23) | (mantissa & 0x7FFFFF);
|
|
||||||
|
|
||||||
return converter.value;
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
int main(){
|
|
||||||
float f1 = makeFloat(0,127,0);
|
|
||||||
printf("Custom 1.0f = %f\n", f1);
|
|
||||||
|
|
||||||
float f2 = makeFloat(1,128,0x200000);
|
|
||||||
printf("Custom -2.5f = %f\n", f2);
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
};
|
|
||||||
|
|
||||||
```
|
|
||||||
Reference in New Issue
Block a user