# How to get the hexadecimal value of a float number in python?

Python | find hexadecimal value of float value: Here, we are going to learn how to find a hexadecimal value of a given float value?
Submitted by IncludeHelp, on April 03, 2019

## Hexadecimal value of a float number

To get the hexadecimal value of a float number we use – float.hex() method, it accepts a float value and returns its hexadecimal value in string format.

Syntax:

```    float.hex(number)
```

Parameter(s): number – a float value to be converted into hexadecimal.

Return value: str – it returns hexadecimal value of number in string format.

Example:

```    Input:
num = 10.23

print("hex value of ", num, " is = ", float.hex(num))

Output:
hex value of  10.23  is =  0x1.475c28f5c28f6p+3
```

Python code to get hexadecimal value of given float number

```# python code to demonstrate example
# of float.hex() function

num = 0.0
print("hex value of ", num, " is = ", float.hex(num))

num = 10.23
print("hex value of ", num, " is = ", float.hex(num))

num = -10.23
print("hex value of ", num, " is = ", float.hex(num))
```

Output

```hex value of  0.0  is =  0x0.0p+0
hex value of  10.23  is =  0x1.475c28f5c28f6p+3
hex value of  -10.23  is =  -0x1.475c28f5c28f6p+3
```

Languages: » C » C++ » C++ STL » Java » Data Structure » C#.Net » Android » Kotlin » SQL
Web Technologies: » PHP » Python » JavaScript » CSS » Ajax » Node.js » Web programming/HTML
Solved programs: » C » C++ » DS » Java » C#
Aptitude que. & ans.: » C » C++ » Java » DBMS
Interview que. & ans.: » C » Embedded C » Java » SEO » HR
CS Subjects: » CS Basics » O.S. » Networks » DBMS » Embedded Systems » Cloud Computing
» Machine learning » CS Organizations » Linux » DOS
More: » Articles » Puzzles » News/Updates