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 téléchargements
Mise à jour 19 nov. 2022

Afficher la licence

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)

Citation pour cette source

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. Récupéré le .

Compatibilité avec les versions de MATLAB
Créé avec R2020a
Compatible avec toutes les versions
Plateformes compatibles
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

Version Publié le Notes de version
1.0.0