0xp0打印0.0(十六进制浮点数字) [英] 0xp0 prints 0.0 (Hexadecimal Floating Point Literal)

查看:282
本文介绍了0xp0打印0.0(十六进制浮点数字)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我只是想知道为什么这会编译?什么意思,因为它编译?

I just wonder why this compiles? and what does it mean since it does compile?

System.out.println(0xp0); // p?

输出:

0.0


推荐答案

这是浮点十六进制文字。

It's a floating point hex literal.


对于十六进制浮点文字,至少需要一位数(在整数中)或者小数部分),指数是必需的,浮点类型后缀是可选的。指数由ASCII字母p或P后跟一个可选的有符号整数表示。

For hexadecimal floating-point literals, at least one digit is required (in either the whole number or the fraction part), and the exponent is mandatory, and the float type suffix is optional. The exponent is indicated by the ASCII letter p or P followed by an optionally signed integer.

参见规范此处

这篇关于0xp0打印0.0(十六进制浮点数字)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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