Unlimited Decimal/Fractional Binary Converter

Conversion to and from a decimal number and a fractional binary number. No limitations on order of magnitude/number of significant digits.
5 descargas
Actualizado 19 nov 2022

Ver licencia

Conversion to and from a decimal number and a fractional binary number. No limitations on order of magnitude and number of significant digits when the decimal number is supplied as a string. You may optionally set the number of significant bits returned or used in conversion. Requires Java.
Example:
% Make a negative number with 250 significant digits and 150 decimal places
decStr = ['-', regexprep([num2str(randi([0 9], 1, 100)), '.', ...
num2str(randi([0 9], 1, 150))], ' ', '')]
% Get the fractional binary number
binStr = dec2fbin(decStr)
% Convert the binary number back to a decimal number
fbin2dec(binStr)
% A double has 53 significant bits, convert with this limitation
fbin2dec(binStr, 53)
% Compare with MATLAB
str2double(decStr)

Citar como

Patrik Forssén (2024). Unlimited Decimal/Fractional Binary Converter (https://www.mathworks.com/matlabcentral/fileexchange/120878-unlimited-decimal-fractional-binary-converter), MATLAB Central File Exchange. Recuperado .

Compatibilidad con la versión de MATLAB
Se creó con R2020a
Compatible con cualquier versión
Compatibilidad con las plataformas
Windows macOS Linux

Community Treasure Hunt

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

Start Hunting!

Decimal-Binary Converter Version 1.0

Versión Publicado Notas de la versión
1.0.0