是否需要将浮动转换为网络订单? [英] Does a float need to be converted to network order?

查看:85
本文介绍了是否需要将浮动转换为网络订单?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如果确实如此,它是在一个小端和一个大端之间

机器我们可以将它作为int或long进行字节交换吗?或者尾数或

指数是否跨越2字节边界?


我可以只调用htonl((long)floatvalue))

If it does, and it is going between a little endian and a big endian
machines can we byte swap it as an int or long? Or does the mantissa or
exponent cross 2 byte boundarys?

Can I just call htonl ( (long) floatvalue))

推荐答案



" sidewinder" < SP ** @ nospam.com>在消息中写道

新闻:5A **************** @ rwcrnsc51.ops.asp.att.net。 ..

"sidewinder" <sp**@nospam.com> wrote in message
news:5A****************@rwcrnsc51.ops.asp.att.net. ..
如果确实如此,它是在一个小端和一个大端之间进行的机器我们可以将它作为int或long进行字节交换吗?或者尾数或
指数是否跨越2字节边界?

我可以只调用htonl((long)floatvalue))
If it does, and it is going between a little endian and a big endian
machines can we byte swap it as an int or long? Or does the mantissa or
exponent cross 2 byte boundarys?

Can I just call htonl ( (long) floatvalue))




正确的问题是:''浮动需要转换为网络

订单如果想要<在此处插入您的操作> ?''


如果你不告诉我们你想用它做什么,我们可以告诉你什么。


一个人需要添加两个整数吗?

Dan



The right question would be: ''does a float need to be converted to network
order if one want to <insert your action here> ?''

If you don''t tell us what you want to do with it, what can we tell you.

Does one need to add two integers?
Dan


Dan Cernat写道:
Dan Cernat wrote:
" sidewinder" < SP ** @ nospam.com>在消息中写道
"sidewinder" <sp**@nospam.com> wrote in message

如果确实如此,它是在一个小端和一个大端之间进行的机器我们可以将它作为int或long进行字节交换吗?或者尾数或
指数是否跨越2字节边界?

我可以只调用htonl((long)floatvalue))

If it does, and it is going between a little endian and a big endian
machines can we byte swap it as an int or long? Or does the mantissa or
exponent cross 2 byte boundarys?

Can I just call htonl ( (long) floatvalue))



正确的问题将是:''如果想要<在此处插入您的操作>,是否需要将浮动转换为网络
订单?''

如果你不告诉我们你想用它做什么,我们可以告诉你什么。

是否需要添加两个整数?



The right question would be: ''does a float need to be converted to network
order if one want to <insert your action here> ?''

If you don''t tell us what you want to do with it, what can we tell you.

Does one need to add two integers?




请原谅我的无知,但为什么不把这个值作为字符串发送并且

转换?没有字节顺序可以担心,并且不知道大多数

协议如何操作,使用字符串文字。



Excuse my ignorance, but why not just send the value as a string and
convert? No endianness to worry about and isnt that how the majority of
protocols operate, with string literals.


Thomas Matthews写道:
Thomas Matthews wrote:
sidewinder写道:
sidewinder wrote:
如果确实如此,它是在一个小端和一个大端之间的机器我们可以将它作为一个int或long来交换?或者尾数或
指数是否跨越2字节边界?

我可以只调用htonl((long)floatvalue))
If it does, and it is going between a little endian and a big endian
machines can we byte swap it as an int or long? Or does the mantissa or
exponent cross 2 byte boundarys?

Can I just call htonl ( (long) floatvalue))


无。 float类型可以很好地工作而不需要转换,
只需使用相应的数学库和输出函数。

但是,如果你问的是网络内容,那就是
平台依赖,您将不得不在新闻组中询问
讨论您的平台。网络内容不是_standard_ C ++语言的一部分,因此这里不再讨论。



No. float types can work perfectly well without being converted,
just use the appropriate math libraries and output functions.

But then, if you were asking about networking stuff, which is
platform dependent, you will have to ask in a newsgroup that
discusses your platform. Networking stuff is not a part
of the _standard_ C++ language and thus not discussed here.




当字节顺序为时,你会被他们搞得一团糟添加到

标准。



you''ll be so fucking bugged out when byte ordering is added to the
standard.


这篇关于是否需要将浮动转换为网络订单?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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