在 CORBA 中表示 null java.lang.Double?
假设我有一个 null java.lang.Double (对象)通过 CORBA 传递。 CORBA 不接受 double 基元类型为 null,因此我必须将其映射到另一个 double(基元)值。
我应该使用的最佳值是多少?
谢谢!
Let's say I have a null java.lang.Double (object) to pass through CORBA. CORBA doesn't accept null for the double primitive type, so I'll have to map it to another double (primitive) value.
What is the best value I should use?
Thanks!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
这是一个很难回答的问题,特别是如果所有双精度值对于该变量所代表的任何内容都有效。
最好的选择是选择 Double.MIN_VALUE 或某个很可能不会使用的值。
但是,您需要确保该值也可以在与 CORBA 交互的其他语言/硬件中表示。
This is a difficult question to answer, especially if all double values are valid for whatever this variable will be representing.
The best bet would be to choose Double.MIN_VALUE or some value that will most likely not be used.
However, you need to make sure this value will also be representable in the other languages/hardware that will be interfacing with CORBA.
CORBA 值类型支持 null;请参阅 CORBA 3.1 规范第 1 部分第 9 章 - http://www.omg .org/spec/CORBA/3.1/Interfaces/PDF/
我认为以下 IDL 语法将定义一个可以表示
double
或null
。如果您无法更改 IDL 并且当前的 IDL 不允许您发送
null
值,那么您应该将 null 视为错误,而不是尝试发送它。从double
值集中窃取合法值(例如Double.MAX_VALUE
)来代表null
会带来问题:Double.MAX_VALUE
作为数据。Double.MAX_VALUE
作为其字面本身进行处理。CORBA value types support null; see Chapter 9 of the CORBA 3.1 spec part 1 - http://www.omg.org/spec/CORBA/3.1/Interfaces/PDF/
I think that the following IDL syntax will define a boxed value type that can represent a
double
ornull
.If you can't change the IDL and the current IDL doesn't allow you to send
null
values, then you should treat a null as an error and not try to send it. Stealing a legitimate value (sayDouble.MAX_VALUE
) from thedouble
value-set to stand for anull
is asking for problems:Double.MAX_VALUE
as data.Double.MAX_VALUE
as its literal self.