浮点数的十六进制值 (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.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代码获取给定浮点数的十六进制值

# 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

Recommended 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中获取浮点数的十六进制值?相关推荐

  1. 如何在Python中获取图片分辨率?——Python实现获取图片分辨率的代码及详解。

    如何在Python中获取图片分辨率?--Python实现获取图片分辨率的代码及详解. 在进行图片处理或者图片分析的时候,获取图片的分辨率信息是必不可少的.Python提供了许多库可以方便地获取图片的分 ...

  2. python获取当前时间戳_如何在Python中获取当前时间戳?

    在Python中可以使用来自模块time.datetime或calendar的函数来获取当前时间戳,代码语句如[import time;ts = time.time() print(ts)]. 在Py ...

  3. 如何在Python中获取文件创建和修改日期/时间?

    我有一个脚本,该脚本需要根据文件创建和修改日期执行一些操作,但必须在Linux和Windows上运行. 在Python中获取文件创建和修改日期/时间的最佳跨平台方法是什么? #1楼 最好的功能是os. ...

  4. python中获取文件大小_如何在Python中获取文件大小

    python中获取文件大小 We can get file size in Python using the os module. 我们可以使用os模块在Python中获取文件大小. Python中的 ...

  5. asp.net mvc 如何在View中获取Url参数的值

    如果url是 /home/index?id=3 直接Request就ok. 但是如果路由设定为:{controller}/{action}/{id} url是 /home/index/3    这时想 ...

  6. 如何在Python中获取字符串的子字符串?

    有没有一种方法可以在Python中为字符串加上字符串,以从第三个字符到字符串的末尾获取新的字符串? 也许像myString[2:end] ? 如果离开第二部分意味着"直到最后",而 ...

  7. python 获取当前目录_如何在Python中获取当前的工作目录?

    python 获取当前目录 To get the current working directory in Python, there is a library function getcwd() i ...

  8. python输出当前时间戳_如何在Python中获取当前时间戳?

    在Python中,有多种方法可以获得当前时间戳.如果希望在Python中获得时间戳,可以使用来自模块time.datetime或calendar的函数. 使用模块time 模块time是提供各种与时间 ...

  9. python 16进制加法_在python中追加2个十六进制值

    我试图在python中附加一些十六进制值,我似乎总是在数字之间得到0x.从我搜索的内容来看,如果不将其转换为点燃的值,这是不可能的?我不确定. a = 0x7b b = 0x80000 hex(a) ...

最新文章

  1. asp.net HC架构 在.netCore上的配置
  2. boost::fusion::pop_front用法的测试程序
  3. qpython怎么用matplotlib_将matplotlib绘图嵌入pyqt的方法示例
  4. 转jmeter --JDBC请求
  5. java串口编程程序_想成为程序员,学编程,Python、Go、Java、C++,你选什么?
  6. oracle 包和包体禁用,Oracle包和包体以及与非包体定义函数、过程的区别
  7. japid-conf目录文件配置
  8. Kontakt 6 for mac - 音频采样器 双版本
  9. PDFelement如何快速地将文本添加到PDF?
  10. 你的企业如何才能留住员工?
  11. 基于SOA的设备智能维护系统架构设计及实现
  12. java如何自定义注解
  13. python七段数码管绘制实验报告_Python绘制七段数码管实例代码
  14. 如何查看NVIDIA显卡显存使用率
  15. 狂神系列之HTML学习笔记
  16. Redies未授权访问
  17. 亿赛通文档安全云服务正式启动
  18. NVIDIA:应将USD作为3D互联网的HTML标准语言
  19. Baidu Nice Slider
  20. 解读本世纪最成功的天才——埃隆·马斯克

热门文章

  1. Rxjs的flatMap使用
  2. Digit sum【暴力+打表】
  3. JVM快速调优手册02:常见的垃圾收集器
  4. vscode Go 1.11.4 编译错误 need Delve built by Go 1.11 or later
  5. 客户端SDK测试思路
  6. LOFTERD18B542F16FF685FD684F427B4…
  7. (转)深入理解最强桌面地图控件GMAP.NET --- 原理篇
  8. [笔记]Linux NTP命令 (ESX适用)
  9. windows phone 学习(4)
  10. git回退历史版本无法上传_Git系列教程(二):版本库中添加文件、版本回退