从C中的32位浮点数中提取位

编程入门 行业动态 更新时间:2024-10-28 03:24:05
本文介绍了从C中的32位浮点数中提取位的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

32位使用IEEE格式以二进制表示.那么如何提取这些位呢?像&这样的按位运算和|不要对他们工作!我基本上想做的是从opencv中的32位浮点图像中提取LSB提前谢谢!

32 bits are represented in binary using the IEEE format. So how can I extract those bits? Bitwise operations like & and | do not work on them! what i basically want to do is extract the LSB from 32 bit float images in opencv thanx in advance!

推荐答案

#include<stdio.h> union abc { float fo; unsigned int no; }; int main() { union abc test; test.fo=36.5; unsigned int x=test.no; for( int i = 0; i < sizeof(float)*8; i++ ) { printf("%d", x & 0x1); x = x >> 1; } return 0; }

这是一种提取浮点数的方法!

this was a way to extract the bits of the float!

更多推荐

从C中的32位浮点数中提取位

本文发布于:2023-08-07 19:56:15,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1321442.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:浮点数

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!