字节序转换器 [英] Endianness Converter

查看:403
本文介绍了字节序转换器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试创建一个读取值的函数,然后将其转换为小端。


我写了这个:

I am trying to make a function to read in a value, then convert it to little endian.

I wrote this:

展开 < span class =codeDivider> | 选择 | Wrap | Line数字

推荐答案

你不能将| =运算符与double一起使用。它只适用于整数类型。


您可能必须使用显式专门化为double。
You can''t use the |= operator with double. It only works for integer types.

You may have to use an explicit specialization for double.


我只是尝试使用unsigned short& ;总之,它对他们来说也不正常吗?无论读入的价值是什么,它输出7543:3
I just tried it with a unsigned short & short, it doesn''t work correctly for them either? No matter what the value it''s meant to be reading in, it output 7543 :3


一个好的旧C联盟有帮助吗?这样的事情:

Does a good old C union help? Something like this:

展开 | 选择 | Wrap | 行号


这篇关于字节序转换器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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