Stax
Tools

IEEE 754 Converter

Convert decimal numbers to IEEE 754 floating point representation.

0sign
10000000exponent (8 bits)
10010010000111111011011mantissa (23 bits)
Decimal
3.141593
Hex
0x40490FDB
Sign
0 (positive)
Exponent
128 (biased), 1 (actual)

การทำงานของ IEEE 754 Converter

IEEE 754 converter แปลงตัวเลขฐานสิบเป็นการแสดงแบบ floating-point binary ความแม่นยำเดี่ยว 32 บิตและความแม่นยำคู่ 64 บิต และย้อนกลับ แสดงบิตเครื่องหมาย เลขชี้กำลังแบบ biased และฟิลด์ mantissa แยกกันพร้อมการระบายสีรหัส ทำให้เป็นเครื่องมือสอนที่มีคุณค่าสำหรับนักศึกษาวิทยาศาสตร์คอมพิวเตอร์

IEEE 754 single precision ใช้ 1 บิตเครื่องหมาย 8 บิตเลขชี้กำลัง (bias 127) และ 23 บิต mantissa ค่าคำนวณจาก: (−1)^sign × 2^(exponent−127) × 1.mantissa ตัวอย่างเช่น เลขทศนิยม 5.75 มี sign=0, exponent=10000001 (129), mantissa=01110000000000000000000 ให้การแสดง hex 32 บิตเป็น 0x40B80000

IEEE 754 สำรอง bit patterns พิเศษสำหรับค่าพิเศษ เลขชี้กำลังเป็นศูนย์ทั้งหมดพร้อม mantissa เป็นศูนย์แสดงถึงบวกหรือลบศูนย์ เลขชี้กำลังเป็นหนึ่งทั้งหมด (255) พร้อม mantissa เป็นศูนย์แสดงถึง ±Infinity เลขชี้กำลังเป็นหนึ่งทั้งหมดพร้อม mantissa ที่ไม่เป็นศูนย์คือ NaN

ความแม่นยำคู่ (64 บิต) ใช้ 1 บิตเครื่องหมาย 11 บิตเลขชี้กำลัง (bias 1023) และ 52 บิต mantissa ให้ตัวเลขทศนิยมที่มีนัยสำคัญประมาณ 15–17 หลัก ความแม่นยำเดี่ยวให้เพียง 6–9 หลัก แอปพลิเคชันทางการเงินและวิทยาศาสตร์หลายตัวต้องการ double; ระบบฝังตัวมักใช้ single เพื่อประหยัดหน่วยความจำ

ใน Python struct.pack('!f', 5.75) เข้ารหัส float เป็นการแสดง IEEE 754 big-endian 4 ไบต์ ใน C การ union ระหว่าง float และ uint32_t ให้การเข้าถึงระดับบิตสำหรับการแสดง floating-point ผลลัพธ์ hex ของ converter ใช้ได้โดยตรงในทั้งสองบริบท

คำถามที่พบบ่อย

What is IEEE 754?
IEEE 754 is the international standard for floating-point arithmetic. It defines how decimal numbers are stored in binary using a sign bit, exponent bits, and a mantissa (fraction) field.
Why do floating point numbers have rounding errors?
Most decimal fractions cannot be represented exactly in binary. For example, 0.1 in binary is a repeating fraction like 0.0001100110011… truncated at the mantissa length, causing small rounding errors.
What is the difference between float and double?
A 32-bit float has 1 sign bit, 8 exponent bits, and 23 mantissa bits (~7 decimal digits precision). A 64-bit double has 1 sign bit, 11 exponent bits, and 52 mantissa bits (~15 decimal digits precision).

เครื่องมือที่เกี่ยวข้อง