Two's Complement Binary Strings

版本 2.0.0.0 (4.3 KB) 作者: Drew Compston
Convert between binary fixed point two's complement strings and decimal numbers.
2.6K 次下载
更新时间 2022/7/7

查看许可证

These functions convert between binary strings and decimal numbers like the built-in MATLAB functions BIN2DEC and DEC2BIN but can accommodate negative integers (via two's complement) and fractional positive and negative numbers (via two's complement fixed point with a binary point in the string).
Note that many fractional numbers that can be represented with a finite number of fractional digits cannot be represented by a finite number of fractional bits (specifically non-powers-of-two fractions like 0.3), which means that FIX2DEC will not always exactly invert DEC2FIX.

引用格式

Drew Compston (2024). Two's Complement Binary Strings (https://www.mathworks.com/matlabcentral/fileexchange/38889-two-s-complement-binary-strings), MATLAB Central File Exchange. 检索来源 .

MATLAB 版本兼容性
创建方式 R2007b
兼容任何版本
平台兼容性
Windows macOS Linux
类别
Help CenterMATLAB Answers 中查找有关 Characters and Strings 的更多信息
致谢

启发作品: DI-155 Acquisition V1.0

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!
版本 已发布 发行说明
2.0.0.0

Mathworks changed the behavior of bitcmp, so I made a new function bitcmpold that reflects the old behavior of the function.

1.0.0.0