如何在python中获取浮点数的十六进制值?
浮點(diǎn)數(shù)的十六進(jìn)制值 (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.
要獲取浮點(diǎn)數(shù)的十六進(jìn)制值,我們使用– float.hex()方法 ,該方法接受一個(gè)浮點(diǎn)值并以字符串格式返回其十六進(jìn)制值。
Syntax:
句法:
float.hex(number)Parameter(s): number – a float value to be converted into hexadecimal.
參數(shù)(一個(gè)或多個(gè)): 數(shù) -一個(gè)浮點(diǎn)值被轉(zhuǎn)換成十六進(jìn)制。
Return value: str – it returns hexadecimal value of number in string format.
返回值:STR -返回字符串格式數(shù)量的十六進(jìn)制值。
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代碼獲取給定浮點(diǎn)數(shù)的十六進(jìn)制值
# 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中將輸入讀取為整數(shù)
Read input as a float in Python
在Python中以浮點(diǎn)形式讀取輸入
Parse a string to float in Python (float() function)
解析要在Python中浮動(dòng)的字符串(float()函數(shù))
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中輸入整數(shù)| 限制用戶僅輸入整數(shù)值
Asking the user for input until a valid response in Python
要求用戶輸入直到Python中的有效響應(yīng)
Input a number in hexadecimal format in Python
在Python中以十六進(jìn)制格式輸入數(shù)字
Input a number in octal format in Python
在Python中以八進(jìn)制格式輸入數(shù)字
Input a number in binary format in Python
在Python中以二進(jìn)制格式輸入數(shù)字
Convert an integer value to the string using str() function in Python
使用Python中的str()函數(shù)將整數(shù)值轉(zhuǎn)換為字符串
Convert a float value to the string using str() function in Python
使用Python中的str()函數(shù)將浮點(diǎn)值轉(zhuǎn)換為字符串
Input and Output Operations with Examples in Python
使用Python中的示例進(jìn)行輸入和輸出操作
Taking multiple inputs from the user using split() method in Python
使用Python中的split()方法從用戶獲取多個(gè)輸入
Fast input / output for competitive programming in Python
快速輸入/輸出,可在Python中進(jìn)行有競爭力的編程
Precision handling in Python
Python中的精確處理
Python print() function with end parameter
帶有結(jié)束參數(shù)的Python print()函數(shù)
翻譯自: https://www.includehelp.com/python/get-the-hexadecimal-value-of-a-float-number.aspx
創(chuàng)作挑戰(zhàn)賽新人創(chuàng)作獎(jiǎng)勵(lì)來咯,堅(jiān)持創(chuàng)作打卡瓜分現(xiàn)金大獎(jiǎng)總結(jié)
以上是生活随笔為你收集整理的如何在python中获取浮点数的十六进制值?的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 不知道Mysql排序的特性,加班到12点
- 下一篇: python中的Lambda表达式/函数