Prerequisite : IEEE Standard 754 Floating Point Numbers
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.
Input : -6744.90 Output : C5D2C733 Input : -263.3 Output : C383A666
- Check whether the number is positive or negative. Save the sign as 0 for positive and 1 for negative, and then convert the number into positive if it is negative.
- Convert the floating point number to binary.
- Separate the decimal part and the whole number part.
- Calculate the exponent(E) and convert it to binary.
- Find the mantissa.
- Concatinate the sign of mantissa, exponent and the mantissa.
- Convert it into hexadecimal.
Let’s write a Python program to represent a floating number as hexadecimal by IEEE 754 standard.
- Python program to convert floating to binary
- Python regex | Check whether the input is Floating point number or not
- Python | Convert Bytearray to Hexadecimal String
- Floating point error in Python
- Floating Action type button in kivy - Python
- Animated Floating Action Button in kivy - Python
- Compute the natural logarithm of one plus each element in floating-point accuracy Using NumPy
- PyQt5 QSpinBox - Getting Pixel ratio as floating value
- Conversion between binary, hexadecimal and decimal numbers using Coden module
- PyQt5 QDockWidget – Setting Floating Property
- PyQt5 QDockWidget – Checking Floating Property
- Inplace vs Standard Operators in Python
- Python | Standard deviation of list
- Standard GUI Unit Converter using Tkinter in Python
- Calculate the average, variance and standard deviation in Python using NumPy
- Mahotas - Checking if two images represent same labeling
- Create the Mean and Standard Deviation of the Data of a Pandas Series
- How to Plot Mean and Standard Deviation in Pandas?
- Compute the mean, standard deviation, and variance of a given NumPy array
- Python Program for Efficient program to print all prime factors of a given number
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to email@example.com. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.
Improved By : mumairanwar