Theo phỏng đoán, mỗi chuỗi HEX chứa hai giá trị dấu phẩy động chính xác đơn, không phải một và 8
ban đầu là một phần của bất kỳ giao thức tin nhắn nào đang được sử dụng, và không phải là một phần của một trong hai phao đó. Với dự đoán đó, tôi nhận được một số con số trông hợp lý:
>>> struct.unpack['>ff', binascii.unhexlify['436d4ccd436d3333']]
[237.3000030517578, 237.1999969482422]
>>> struct.unpack['>ff', binascii.unhexlify['436d999a436e0000']]
[237.60000610351562, 238.0]
Và để củng cố tính hợp lý, đây là những gì tôi nhận được bằng cách mã hóa các giá trị điểm số 1 chữ số tương ứng::
>>> binascii.hexlify[struct.pack['>ff', 237.3, 237.2]]
b'436d4ccd436d3333'
>>> binascii.hexlify[struct.pack['>ff', 237.6, 238.0]]
b'436d999a436e0000'
Xem thảo luận
Cải thiện bài viết
Lưu bài viết
Xem thảo luận
Cải thiện bài viết
Lưu bài viết
Đọc
Given a floating point number, the task is to find the hexadecimal representation for the number by IEEE 754 standard.
The IEEE Standard for Floating-Point Arithmetic [IEEE 754] is a technical standard for floating-point computation which was established in 1985 by the Institute of Electrical and Electronics Engineers [IEEE]. The standard addressed many problems found in the diverse floating point implementations that made them difficult to use reliably and reduced their
portability. IEEE Standard 754 floating point is the most common representation today for real numbers on computers, including Intel-based PC’s, Macs, and most Unix platforms.
Bàn luận
Input : -6744.90 Output : C5D2C733 Input : -263.3 Output : C383A666
Điều kiện tiên quyết: Số điểm nổi tiêu chuẩn 754 của IEEE, một số điểm nổi, nhiệm vụ là tìm biểu diễn thập lục phân cho số của IEEE 754 Standard. Tiêu chuẩn IEEE cho số học nổi [IEEE 754] được thành lập vào năm 1985 bởi Viện Kỹ sư Điện và Điện tử [IEEE]. Tiêu chuẩn giải quyết nhiều vấn đề được tìm thấy trong các triển khai điểm nổi đa dạng khiến chúng khó sử dụng một cách đáng tin cậy và giảm tính di động của chúng. Điểm nổi tiêu chuẩn 754 của IEEE là đại diện phổ biến nhất hiện nay đối với các số thực trên máy tính, bao gồm PC, MACS, MACS và hầu hết các nền tảng Unix. & NBSP; & NBSP;
- Ví dụ: & nbsp; & nbsp;
- Cách tiếp cận: & nbsp; & nbsp;
- Kiểm tra xem số là dương hay âm. Lưu dấu là 0 cho dương và 1 cho âm, sau đó chuyển đổi số thành dương nếu nó âm.
- Chuyển đổi số điểm nổi thành nhị phân.
- Tách phần thập phân và toàn bộ phần số.
- Tính toán số mũ [e] và chuyển đổi nó thành nhị phân.
- Tìm Mantissa.
Concatenate dấu hiệu của mantissa, số mũ và mantissa.
Python3
Chuyển đổi nó thành thập lục phân.
Hãy để viết một chương trình Python để thể hiện một số nổi là HexAdecimal của IEEE 754 Standard. & NBSP; & NBSP;
def
float_bin[my_number, places
=
3
]:
____1010
>>> binascii.hexlify[struct.pack['>ff', 237.3, 237.2]]
b'436d4ccd436d3333'
>>> binascii.hexlify[struct.pack['>ff', 237.6, 238.0]]
b'436d999a436e0000'
2>>> binascii.hexlify[struct.pack['>ff', 237.3, 237.2]]
b'436d4ccd436d3333'
>>> binascii.hexlify[struct.pack['>ff', 237.6, 238.0]]
b'436d999a436e0000'
3>>> binascii.hexlify[struct.pack['>ff', 237.3, 237.2]]
b'436d4ccd436d3333'
>>> binascii.hexlify[struct.pack['>ff', 237.6, 238.0]]
b'436d999a436e0000'
4>>> binascii.hexlify[struct.pack['>ff', 237.3, 237.2]]
b'436d4ccd436d3333'
>>> binascii.hexlify[struct.pack['>ff', 237.6, 238.0]]
b'436d999a436e0000'
5
>>> binascii.hexlify[struct.pack['>ff', 237.3, 237.2]]
b'436d4ccd436d3333'
>>> binascii.hexlify[struct.pack['>ff', 237.6, 238.0]]
b'436d999a436e0000'
7=
>>> binascii.hexlify[struct.pack['>ff', 237.3, 237.2]]
b'436d4ccd436d3333'
>>> binascii.hexlify[struct.pack['>ff', 237.6, 238.0]]
b'436d999a436e0000'
9Input : -6744.90 Output : C5D2C733 Input : -263.3 Output : C383A6660
Input : -6744.90 Output : C5D2C733 Input : -263.3 Output : C383A66622
=
Input : -6744.90 Output : C5D2C733 Input : -263.3 Output : C383A6664
>>> binascii.hexlify[struct.pack['>ff', 237.3, 237.2]]
b'436d4ccd436d3333'
>>> binascii.hexlify[struct.pack['>ff', 237.6, 238.0]]
b'436d999a436e0000'
2Input : -6744.90 Output : C5D2C733 Input : -263.3 Output : C383A6664
Input : -6744.90 Output : C5D2C733 Input : -263.3 Output : C383A6667
Input : -6744.90 Output : C5D2C733 Input : -263.3 Output : C383A6668
Input : -6744.90 Output : C5D2C733 Input : -263.3 Output : C383A6669
>>> binascii.hexlify[struct.pack['>ff', 237.3, 237.2]]
b'436d4ccd436d3333'
>>> binascii.hexlify[struct.pack['>ff', 237.6, 238.0]]
b'436d999a436e0000'
48
18
28
3
8
5 8
68
7 8
88
9
def
0def
1=
>>> binascii.hexlify[struct.pack['>ff', 237.3, 237.2]]
b'436d4ccd436d3333'
>>> binascii.hexlify[struct.pack['>ff', 237.6, 238.0]]
b'436d999a436e0000'
2Input : -6744.90 Output : C5D2C733 Input : -263.3 Output : C383A6664
def
5>>> binascii.hexlify[struct.pack['>ff', 237.3, 237.2]]
b'436d4ccd436d3333'
>>> binascii.hexlify[struct.pack['>ff', 237.6, 238.0]]
b'436d999a436e0000'
5Input : -6744.90 Output : C5D2C733 Input : -263.3 Output : C383A6669__12
def
0float_bin[my_number, places
1=
float_bin[my_number, places
3 float_bin[my_number, places
4
Input : -6744.90 Output : C5D2C733 Input : -263.3 Output : C383A6664
float_bin[my_number, places
6def
9float_bin[my_number, places
8float_bin[my_number, places
9>>> binascii.hexlify[struct.pack['>ff', 237.3, 237.2]]
b'436d4ccd436d3333'
>>> binascii.hexlify[struct.pack['>ff', 237.6, 238.0]]
b'436d999a436e0000'
5def
0
>>> binascii.hexlify[struct.pack['>ff', 237.3, 237.2]]
b'436d4ccd436d3333'
>>> binascii.hexlify[struct.pack['>ff', 237.6, 238.0]]
b'436d999a436e0000'
0____6 =
4>>> binascii.hexlify[struct.pack['>ff', 237.3, 237.2]]
b'436d4ccd436d3333'
>>> binascii.hexlify[struct.pack['>ff', 237.6, 238.0]]
b'436d999a436e0000'
4>>> binascii.hexlify[struct.pack['>ff', 237.3, 237.2]]
b'436d4ccd436d3333'
>>> binascii.hexlify[struct.pack['>ff', 237.6, 238.0]]
b'436d999a436e0000'
5def
0
Input : -6744.90 Output : C5D2C733 Input : -263.3 Output : C383A6662
Input : -6744.90 Output : C5D2C733 Input : -263.3 Output : C383A6669
=
3
1
3
3 3
4
def
3
6
3
8=
]:
0
]:
2 ]:
3]:
0 ]:
5
def
03
8=
]:
9
def
0
1=
1float_bin[my_number, places
8
Input : -6744.90 Output : C5D2C733 Input : -263.3 Output : C383A6664
6]:
9>>> binascii.hexlify[struct.pack['>ff', 237.3, 237.2]]
b'436d4ccd436d3333'
>>> binascii.hexlify[struct.pack['>ff', 237.6, 238.0]]
b'436d999a436e0000'
5
>>> binascii.hexlify[struct.pack['>ff', 237.3, 237.2]]
b'436d4ccd436d3333'
>>> binascii.hexlify[struct.pack['>ff', 237.6, 238.0]]
b'436d999a436e0000'
00__ >>> binascii.hexlify[struct.pack['>ff', 237.3, 237.2]]
b'436d4ccd436d3333'
>>> binascii.hexlify[struct.pack['>ff', 237.6, 238.0]]
b'436d999a436e0000'
02
>>> binascii.hexlify[struct.pack['>ff', 237.3, 237.2]]
b'436d4ccd436d3333'
>>> binascii.hexlify[struct.pack['>ff', 237.6, 238.0]]
b'436d999a436e0000'
04=
>>> binascii.hexlify[struct.pack['>ff', 237.3, 237.2]]
b'436d4ccd436d3333'
>>> binascii.hexlify[struct.pack['>ff', 237.6, 238.0]]
b'436d999a436e0000'
06=
>>> binascii.hexlify[struct.pack['>ff', 237.3, 237.2]]
b'436d4ccd436d3333'
>>> binascii.hexlify[struct.pack['>ff', 237.6, 238.0]]
b'436d999a436e0000'
08‘
‘
]:
2
>>> binascii.hexlify[struct.pack['>ff', 237.3, 237.2]]
b'436d4ccd436d3333'
>>> binascii.hexlify[struct.pack['>ff', 237.6, 238.0]]
b'436d999a436e0000'
23def
0
>>> binascii.hexlify[struct.pack['>ff', 237.3, 237.2]]
b'436d4ccd436d3333'
>>> binascii.hexlify[struct.pack['>ff', 237.6, 238.0]]
b'436d999a436e0000'
04=
>>> binascii.hexlify[struct.pack['>ff', 237.3, 237.2]]
b'436d4ccd436d3333'
>>> binascii.hexlify[struct.pack['>ff', 237.6, 238.0]]
b'436d999a436e0000'
27>>> binascii.hexlify[struct.pack['>ff', 237.3, 237.2]]
b'436d4ccd436d3333'
>>> binascii.hexlify[struct.pack['>ff', 237.6, 238.0]]
b'436d999a436e0000'
4>>> binascii.hexlify[struct.pack['>ff', 237.3, 237.2]]
b'436d4ccd436d3333'
>>> binascii.hexlify[struct.pack['>ff', 237.6, 238.0]]
b'436d999a436e0000'
29def
0
>>> binascii.hexlify[struct.pack['>ff', 237.3, 237.2]]
b'436d4ccd436d3333'
>>> binascii.hexlify[struct.pack['>ff', 237.6, 238.0]]
b'436d999a436e0000'
16
6=
]:
9‘
def
0
>>> binascii.hexlify[struct.pack['>ff', 237.3, 237.2]]
b'436d4ccd436d3333'
>>> binascii.hexlify[struct.pack['>ff', 237.6, 238.0]]
b'436d999a436e0000'
04=
>>> binascii.hexlify[struct.pack['>ff', 237.3, 237.2]]
b'436d4ccd436d3333'
>>> binascii.hexlify[struct.pack['>ff', 237.6, 238.0]]
b'436d999a436e0000'
27>>> binascii.hexlify[struct.pack['>ff', 237.3, 237.2]]
b'436d4ccd436d3333'
>>> binascii.hexlify[struct.pack['>ff', 237.6, 238.0]]
b'436d999a436e0000'
4>>> binascii.hexlify[struct.pack['>ff', 237.3, 237.2]]
b'436d4ccd436d3333'
>>> binascii.hexlify[struct.pack['>ff', 237.6, 238.0]]
b'436d999a436e0000'
29def
0
>>> binascii.hexlify[struct.pack['>ff', 237.3, 237.2]]
b'436d4ccd436d3333'
>>> binascii.hexlify[struct.pack['>ff', 237.6, 238.0]]
b'436d999a436e0000'
16
6=
]:
9def
0
>>> binascii.hexlify[struct.pack['>ff', 237.3, 237.2]]
b'436d4ccd436d3333'
>>> binascii.hexlify[struct.pack['>ff', 237.6, 238.0]]
b'436d999a436e0000'
10
6=
]:
9
>>> binascii.hexlify[struct.pack['>ff', 237.3, 237.2]]
b'436d4ccd436d3333'
>>> binascii.hexlify[struct.pack['>ff', 237.6, 238.0]]
b'436d999a436e0000'
41 >>> binascii.hexlify[struct.pack['>ff', 237.3, 237.2]]
b'436d4ccd436d3333'
>>> binascii.hexlify[struct.pack['>ff', 237.6, 238.0]]
b'436d999a436e0000'
42
>>> binascii.hexlify[struct.pack['>ff', 237.3, 237.2]]
b'436d4ccd436d3333'
>>> binascii.hexlify[struct.pack['>ff', 237.6, 238.0]]
b'436d999a436e0000'
55=
>>> binascii.hexlify[struct.pack['>ff', 237.3, 237.2]]
b'436d4ccd436d3333'
>>> binascii.hexlify[struct.pack['>ff', 237.6, 238.0]]
b'436d999a436e0000'
57Input : -6744.90 Output : C5D2C733 Input : -263.3 Output : C383A6669
]:
9>>> binascii.hexlify[struct.pack['>ff', 237.3, 237.2]]
b'436d4ccd436d3333'
>>> binascii.hexlify[struct.pack['>ff', 237.6, 238.0]]
b'436d999a436e0000'
60
>>> binascii.hexlify[struct.pack['>ff', 237.3, 237.2]]
b'436d4ccd436d3333'
>>> binascii.hexlify[struct.pack['>ff', 237.6, 238.0]]
b'436d999a436e0000'
62=
>>> binascii.hexlify[struct.pack['>ff', 237.3, 237.2]]
b'436d4ccd436d3333'
>>> binascii.hexlify[struct.pack['>ff', 237.6, 238.0]]
b'436d999a436e0000'
10
6 >>> binascii.hexlify[struct.pack['>ff', 237.3, 237.2]]
b'436d4ccd436d3333'
>>> binascii.hexlify[struct.pack['>ff', 237.6, 238.0]]
b'436d999a436e0000'
66
>>> binascii.hexlify[struct.pack['>ff', 237.3, 237.2]]
b'436d4ccd436d3333'
>>> binascii.hexlify[struct.pack['>ff', 237.6, 238.0]]
b'436d999a436e0000'
68=
>>> binascii.hexlify[struct.pack['>ff', 237.3, 237.2]]
b'436d4ccd436d3333'
>>> binascii.hexlify[struct.pack['>ff', 237.6, 238.0]]
b'436d999a436e0000'
62Input : -6744.90 Output : C5D2C733 Input : -263.3 Output : C383A6669
>>> binascii.hexlify[struct.pack['>ff', 237.3, 237.2]]
b'436d4ccd436d3333'
>>> binascii.hexlify[struct.pack['>ff', 237.6, 238.0]]
b'436d999a436e0000'
72
>>> binascii.hexlify[struct.pack['>ff', 237.3, 237.2]]
b'436d4ccd436d3333'
>>> binascii.hexlify[struct.pack['>ff', 237.6, 238.0]]
b'436d999a436e0000'
68=
Input : -6744.90 Output : C5D2C733 Input : -263.3 Output : C383A6667
>>> binascii.hexlify[struct.pack['>ff', 237.3, 237.2]]
b'436d4ccd436d3333'
>>> binascii.hexlify[struct.pack['>ff', 237.6, 238.0]]
b'436d999a436e0000'
77>>> binascii.hexlify[struct.pack['>ff', 237.3, 237.2]]
b'436d4ccd436d3333'
>>> binascii.hexlify[struct.pack['>ff', 237.6, 238.0]]
b'436d999a436e0000'
788
3
>>> binascii.hexlify[struct.pack['>ff', 237.3, 237.2]]
b'436d4ccd436d3333'
>>> binascii.hexlify[struct.pack['>ff', 237.6, 238.0]]
b'436d999a436e0000'
55=
>>> binascii.hexlify[struct.pack['>ff', 237.3, 237.2]]
b'436d4ccd436d3333'
>>> binascii.hexlify[struct.pack['>ff', 237.6, 238.0]]
b'436d999a436e0000'
83]:
0]:
5>>> binascii.hexlify[struct.pack['>ff', 237.3, 237.2]]
b'436d4ccd436d3333'
>>> binascii.hexlify[struct.pack['>ff', 237.6, 238.0]]
b'436d999a436e0000'
86>>> binascii.hexlify[struct.pack['>ff', 237.3, 237.2]]
b'436d4ccd436d3333'
>>> binascii.hexlify[struct.pack['>ff', 237.6, 238.0]]
b'436d999a436e0000'
87
>>> binascii.hexlify[struct.pack['>ff', 237.3, 237.2]]
b'436d4ccd436d3333'
>>> binascii.hexlify[struct.pack['>ff', 237.6, 238.0]]
b'436d999a436e0000'
89=
>>> binascii.hexlify[struct.pack['>ff', 237.3, 237.2]]
b'436d4ccd436d3333'
>>> binascii.hexlify[struct.pack['>ff', 237.6, 238.0]]
b'436d999a436e0000'
2>>> binascii.hexlify[struct.pack['>ff', 237.3, 237.2]]
b'436d4ccd436d3333'
>>> binascii.hexlify[struct.pack['>ff', 237.6, 238.0]]
b'436d999a436e0000'
92______
Input : -6744.90 Output : C5D2C733 Input : -263.3 Output : C383A66600
=
Input : -6744.90 Output : C5D2C733 Input : -263.3 Output : C383A66602
float_bin[my_number, places
4Input : -6744.90 Output : C5D2C733 Input : -263.3 Output : C383A66604__
3
3
Input : -6744.90 Output : C5D2C733 Input : -263.3 Output : C383A66620