如何在python中获取浮点数的十六进制值?
浮點數的十六進制值 (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.
要獲取浮點數的十六進制值,我們使用– float.hex()方法 ,該方法接受一個浮點值并以字符串格式返回其十六進制值。
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.
返回值:STR -返回字符串格式數量的十六進制值。
Example:
例:
Input:num = 10.23print("hex value of ", num, " is = ", float.hex(num))Output:hex value of 10.23 is = 0x1.475c28f5c28f6p+3Python code to get hexadecimal value of given float number
Python代碼獲取給定浮點數的十六進制值
# python code to demonstrate example # of float.hex() functionnum = 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+3Recommended posts
推薦的帖子
Read input as an integer in Python
在Python中將輸入讀取為整數
Read input as a float in Python
在Python中以浮點形式讀取輸入
Parse a string to float in Python (float() function)
解析要在Python中浮動的字符串(float()函數)
How do you read from stdin in Python?
您如何從Python的stdin中讀取信息?
Asking the user for integer input in Python | Limit the user to input only integer value
要求用戶在Python中輸入整數| 限制用戶僅輸入整數值
Asking the user for input until a valid response in Python
要求用戶輸入直到Python中的有效響應
Input a number in hexadecimal format in Python
在Python中以十六進制格式輸入數字
Input a number in octal format in Python
在Python中以八進制格式輸入數字
Input a number in binary format in Python
在Python中以二進制格式輸入數字
Convert an integer value to the string using str() function in Python
使用Python中的str()函數將整數值轉換為字符串
Convert a float value to the string using str() function in Python
使用Python中的str()函數將浮點值轉換為字符串
Input and Output Operations with Examples in Python
使用Python中的示例進行輸入和輸出操作
Taking multiple inputs from the user using split() method in Python
使用Python中的split()方法從用戶獲取多個輸入
Fast input / output for competitive programming in Python
快速輸入/輸出,可在Python中進行有競爭力的編程
Precision handling in Python
Python中的精確處理
Python print() function with end parameter
帶有結束參數的Python print()函數
翻譯自: https://www.includehelp.com/python/get-the-hexadecimal-value-of-a-float-number.aspx
創作挑戰賽新人創作獎勵來咯,堅持創作打卡瓜分現金大獎總結
以上是生活随笔為你收集整理的如何在python中获取浮点数的十六进制值?的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 不知道Mysql排序的特性,加班到12点
- 下一篇: Java LineNumberInput