简体   繁体   English

不使用IEEE754浮点的C ++编译器/平台

[英]C++ compilers/platforms that don't use IEEE754 floating point

I'm working on updating a serialization library to add support for serializing floating point in a portable manner. 我正在更新序列化库,以便以可移植的方式添加对浮点序列化的支持。 Ideally I'd like to be able to test the code in an environment where IEEE754 isn't supported. 理想情况下,我希望能够在不支持IEEE754的环境中测试代码。 Would it be sufficient to test using a soft-float library? 使用软浮动库进行测试是否足够? Or any other suggestions about how I can properly test the code? 或者关于如何正确测试代码的任何其他建议?

Free toolchains that you can find for ARM (embedded Linux) development, mostly do not support hard-float operations but soft-float only. 您可以在ARM(嵌入式Linux)开发中找到的免费工具链,大多数不支持硬浮动操作,而只支持软浮动。 You could try with one of these (ie CodeSourcery ) but you would need some kind of a platform to run the compiled code (real HW or QEMU). 您可以尝试使用其中一种(即CodeSourcery ),但是您需要某种平台来运行已编译的代码(真正的HW或QEMU)。

Or if you would want to do the same but on x86 machine, take a look at: Using software floating point on x86 linux 或者如果您想在x86机器上执行相同的操作,请查看: 在x86 linux上使用软件浮点

Should your library work on a system where both hardware floating point and soft-float are not available ? 您的库是否应该在硬件浮点和软浮点都不可用的系统上工作? If so, if you test using a compiler with soft-float, your code may not compile/work on such a system. 如果是这样,如果使用带有soft-float的编译器进行测试,则代码可能无法在此类系统上编译/工作。

Personally, I would test the library on a ARM9 system with a gcc compiler without soft-float. 就个人而言,我会使用没有soft-float的gcc编译器在ARM9系统上测试库。

Not an answer to your actual question, but describing what you must do to solve the problem. 不是你的实际问题的答案,而是描述你必须做些什么来解决问题。

If you want to support "different" floating point formats, your code would have to understand the internal format of floats [unless you only support "same architecture both ends"], pick the floating point number apart into your own format [which of course may be IEEE-754, but beware of denormals, 128-bit long doubles, NaN, INFINITY, and other "exception values", and of course out of range numbers], and then put it back together to the format required by the other end. 如果你想支持“不同的”浮点格式,你的代码必须理解浮点数的内部格式[除非你只支持“相同的架构两端”],选择浮点数分成你自己的格式[当然当然可能是IEEE-754,但要注意非正规,128位长双精度,NaN,INFINITY和其他“异常值”,当然还有超出范围的数字],然后将它们重新组合成另一个所需的格式结束。 If you are not doing this, there is no point in hunting down a non-IEEE-754 system, because it won't work. 如果你不是这样做的话,追求非IEEE-754系统是没有意义的,因为它不会起作用。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM