-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfloat.h
More file actions
38 lines (26 loc) · 932 Bytes
/
float.h
File metadata and controls
38 lines (26 loc) · 932 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
#ifndef FLOAT_H
#define FLOAT_H
#include <string>
#include <vector>
#include <iostream>
#include <cstdio>
#include <cmath>
using namespace std;
//编码函数:浮点数转化成二进制码
//单精度浮点数转化成32位 IEEE-754编码
unsigned int floatToBinary( float );
//双精度浮点数转化成64位 IEEE-754编码
//精度范围:小数点后15位
unsigned long long doubleToBinary( double );
//long double浮点数转化成80位 IEEE-754编码
//first的第16位+second
//精度范围:小数点后19位
pair<unsigned long long,unsigned long long> longDoubleToBinary( long double );
//译码函数:二进制码转化成浮点数
//精度范围:小数点后6位
float binaryToFloat ( unsigned int );
//精度范围:小数点后15位
double binaryToDouble(unsigned long long);
//精度范围:小数点后19位
long double binaryToLongDouble(pair<unsigned long long,unsigned long long> x);
#endif