使用浮点数的基础位表示 [英] Using underlying bit representations of floats

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

问题描述




我想知道是否有一种方法可以使用基础位

表示浮点数。我有兴趣在

MISRA C:2004规则中创建违规行为基础位表示不得使用

使用


我使用按位运算符进行了treid但这些不可编译。


有没有办法可以使用浮点数位表示?

Hi

I am wondering if there is a way of using the underlying bit
representations of floats. I am interested in creating a violation in
MISRA C:2004 of rule "The underlying bit representations shall not be
used"

I have treid using bitwise operators but these are not compilable.

Is there a way I can use bit representations of floats?

推荐答案

ha ******** @ googlemail.com aécrit:


我想知道是否有一种方法可以使用浮点数的基础位表示。我有兴趣在MISRA C:2004规则中创建违规行为不应使用基础位表示

我使用按位运算符进行了treid但这些是不可编译。

有没有办法可以使用浮动的位表示?
Hi

I am wondering if there is a way of using the underlying bit
representations of floats. I am interested in creating a violation in
MISRA C:2004 of rule "The underlying bit representations shall not be
used"

I have treid using bitwise operators but these are not compilable.

Is there a way I can use bit representations of floats?



如果您使用IEEE754我们有:


typedef struct {

unsigned int mantissa1;

unsigned int mantissa0:31;

unsigned int one:1;

unsigned int exponent:15;

unsigned int negative:1;

unsigned int empty:16;

} _longDouble; // 80位英特尔长双

typedef结构{

unsigned int mantissa1;

unsigned int mantissa0:20;

unsigned int exponent:11;

unsigned int sign:1;

} _Double; // 64位双


typedef struct {

unsigned int尾数:23;

unsigned int exponent:8;

unsigned int sign:1;

} _Float; // 32位浮动


If you use IEEE754 we have:

typedef struct {
unsigned int mantissa1;
unsigned int mantissa0:31;
unsigned int one:1;
unsigned int exponent:15;
unsigned int negative:1;
unsigned int empty:16;
} _longDouble; // 80 bits intel long double
typedef struct {
unsigned int mantissa1;
unsigned int mantissa0:20;
unsigned int exponent:11;
unsigned int sign:1;
} _Double; // 64 bit double

typedef struct {
unsigned int mantissa:23;
unsigned int exponent:8;
unsigned int sign:1;
} _Float; // 32 bit float


抱歉一些拼写错误


规则12.12状态浮动类型的基础位表示

变量不得使用

Sorry some typos

Rule 12.12 states "the underlying bit representations of floating type
variables shall not be used"


谢谢你可以解释一下这是如何使用基础位

浮点/双打的表示。

Thanks for that can you please explain how this uses the underlying bit
representations of floats/doubles.


这篇关于使用浮点数的基础位表示的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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