浮点Endianness? [英] Floating point Endianness?

查看:142
本文介绍了浮点Endianness?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在为一个实时离岸模拟器编写一个客户端和一个服务器,由于我必须通过套接字发送大量数据,我使用二进制数据来最大限度地发送数据。我已经知道整数字节序,以及如何使用htonl和ntohl来避免字节序问题,但我的应用程序,几乎所有的模拟软件,处理了很多浮点数。

I'm writing a client and a server for a realtime offshore simulator, and, as I have to send a lot of data through a socket, I'm using binary data to maximize the ammount of data I can send. I already know about integers endianness, and how to use htonl and ntohl to circumvent endianness issues, but my application, as almost all simulation software, deals with a lot of floats.

我的问题是:在处理二进制格式的浮点数有一些问题的字节序吗?我知道我的代码将运行的所有机器使用IEEE实现浮点,但是在处理浮点时有一些端序问题?

My question is: Is there some issue of endianness whean dealing with binary formats of floating point numbers? I know that all the machines where my code will run use IEEE implementation of floating points, but is there some endianness issue when dealing with floats?

由于我只能访问机器有相同的endian,我不能自己测试这个。

Since I only have access to machines with the same endian, I cannot test this by myself. So, I'll be glad if someone can help me with this.

提前感谢。

推荐答案

是的,浮点可以是endianess依赖的。请参见 http://stackoverflow.com/questions / 2782725 / converted-float-values-from-big-endian-to-little-endian / 2782742#2782742 了解详情,请务必阅读评论。

Yes, floating point can be endianess dependent. See http://stackoverflow.com/questions/2782725/converting-float-values-from-big-endian-to-little-endian/2782742#2782742 for info, be sure to read the comments.

这篇关于浮点Endianness?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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