File Exchange

image thumbnail

Two's Complement Binary Strings

version 1.0 (4.4 KB) by

Convert between binary fixed point two's complement strings and decimal numbers.



View License

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.

Comments and Ratings (2)

akshay rathod

error is showing if negative, it says the assumed datatyme must be integer type name

MATLAB Release
MATLAB 7.5 (R2007b)

Inspired: DI-155 Acquisition V1.0

Download apps, toolboxes, and other File Exchange content using Add-On Explorer in MATLAB.

» Watch video