我应该将什么字符串传递给 java.lang.Long.parseLong() 以返回 NaN?
不幸的是,我不能使用像 Long.Nan 这样的表达式,因为该字符串实际上是来自不同 C 模块的返回值。是否有一个字符串可以传递给 parseLong() 以返回 NaN ?
I unfortunately cant use expressions like Long.Nan as the string is actually a return value from a different C module. Is there a string I can pass to parseLong() to return an NaN ?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(5)
没有 Long.NaN ——你很困惑。
对于 Double.NaN,这样怎么样:(
编辑:显而易见的方法是传入任何无效双精度的字符串,例如空字符串或 NaN)
There is no Long.NaN -- you are confused.
For Double.NaN, how about this:
(edit: and the obvious approach is to pass in any string that is an invalid double, e.g. the empty string or NaN)
不存在
Long
.NaN
,当您认为 long 中的每个位模式都表示 [Long.MIN_VALUE
,范围内的有效整数时,这是有意义的Long.MAX_VALUE
]。您可能会考虑尝试获取 < 的位模式改为代码>Double.NaN。
There is no such thing as
Long
.NaN
, which makes sense when you consider that every bit pattern within long represents a valid integer within the range of [Long.MIN_VALUE
,Long.MAX_VALUE
].You might consider trying to get the bit pattern of
Double.NaN
instead.龙南? Java 中不存在这种情况。您只有 Long.MIN_VALUE 和 Long.MAX_VALUE
"Nan" 作为
Double.parseDouble(String)
的参数,如果您想要的话,则将 Double.NaN 作为值。Long.Nan? That doesn't exist in Java. You only have Long.MIN_VALUE and Long.MAX_VALUE
"Nan" as argument to
Double.parseDouble(String)
gives Double.NaN as value if that is what you want.java.lang.Long
表示 64 位有符号整数值,而NaN
仅在浮点计算中引入。话虽这么说,没有特殊的字符串返回 LongNaN
,但您可以例如使用:java.lang.Long
represent 64-bit signed integral value, whileNaN
is introduced only in floating-point computations. That being said there is no special string return LongNaN
, but you can for instance use:Java 对于浮点数据类型只有 NaN 的概念,而不是像
Long
这样的整数数据类型。Java only has a concept of NaN for floating point datatypes, not integer ones such as
Long
.