将Java浮点数表示为十六进制数字 [英] Java floating-point numbers representation as a hexadecimal numbers

查看:176
本文介绍了将Java浮点数表示为十六进制数字的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

为什么 0x1p3 等于 8.0 ?为什么 0x1e3 等于 483 ,而 0x1e3d 等于 7741 ?自 1e3d 等于 1000.0

解决方案> 0x1e3 0x1e3d 是十六进制整数文字。请注意, e d 是十六进制数字,而不是指数指标或 double type指示符。



1e3d 是一个十进制浮点<文字。 e 是指数指标, d 表示这是一个 double 而不是 float



符号 0x1p3 是一种以十六进制表示浮点文字的方式,您可以在 Java语言规范第3.10.2节。这意味着1次2的权力3;指数是二进制的(所以,它是2的权力,而不是10的权力)。


Why does 0x1p3 equal 8.0? Why does 0x1e3 equal 483, whereas 0x1e3d equals 7741? It is confusing since 1e3d equals 1000.0.

解决方案

0x1e3 and 0x1e3d are hexadecimal integer literals. Note that e and d are hexadecimal digits, not the exponent indicator or double type indicator in this case.

1e3d is a decimal floating-point literal. The e is the exponent indicator, the d says that this is a double rather than a float.

The notation 0x1p3 is a way to express a floating-point literal in hexadecimal, as you can read in section 3.10.2 of the Java Language Specification. It means 1 times 2 to the power 3; the exponent is binary (so, it's 2-to-the-power instead of 10-to-the-power).

这篇关于将Java浮点数表示为十六进制数字的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆