Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7733021
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T06:52:46+00:00 2026-06-01T06:52:46+00:00

Is there a Matlab function that returns the binary representation of a float number?

  • 0

Is there a Matlab function that returns the binary representation of a float number?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-01T06:52:48+00:00Added an answer on June 1, 2026 at 6:52 am

    In Matlab, one can use Java JDK functions.

    The short answer for converting float (single precision 32-bit number) in Matlab to a binary string representation might be:

    flt=3.14
    import java.lang.Integer java.lang.Float;
    Integer.toBinaryString(Float.floatToIntBits(flt))
    

    The long answer: conversion of float (single precision 32-bit number) in Matlab to a binary string representation

    function out=float2binstring(flt)
    % converts a float number to binary in matlab according to IEEE754
    %
    % Usage:
    % float2binstring(-3.14)
    %
    % http://www.h-schmidt.net/FloatApplet/IEEE754.html
    %
    % Limitations:
    % Rounding errors: Not every decimal number can be expressed exactly as a     floating
    % point number. This can be seen when entering "0.1" and examining its binary     representation which is either slightly smaller or larger, depending on the last bit. 
    %
    % Andrej Mosat, nospam@mosi.sk
    % 03/2012
    % v0.0
    % License: GNU GPL
    %
    % See also: BINSTRING2FLOAT
    
    
    % this is a trick to use java JDK should be installed, tested on Matlab R2010
    import java.lang.Integer java.lang.Float;
    
    if ( ~isnumeric(flt) )
        error('input must be a number');
    end
    
    out=Integer.toBinaryString(Float.floatToIntBits(flt));
    end
    

    And a conversion of binary string to float with a little overhead:

    function out=binstring2float(binstr)
        % converts a binary string to float number according to IEEE754
        %
        % Usage:
        % binstring2float('11000000010010001111010111000011')
        %   -3.14
        %
        % 
        % http://www.h-schmidt.net/FloatApplet/IEEE754.html
        %
        % Limitations:
        % Rounding errors: Not every decimal number can be expressed exactly as a floating
        % point number. This can be seen when entering "0.1" and examining its binary representation which is either slightly smaller or larger, depending on the last bit. 
        %
        % Andrej Mosat, nospam@mosi.sk
        % 03/2012
        % v0.0
        % License: GNU GPL
        %
        % See also: FLOAT2BINSTRING
    
        import java.lang.Long java.lang.Float;
    
        if isequal(class(binstr), 'java.lang.String')
                binstr=char(binstr);
        end
    
        if ( ~isstr(binstr) )
            error('input must be a binary string');                                             
        end
        % Error handling for binary strings should be added here
    
        % the sign is negative
    
        if binstr(2)=='1'
            binstr(2)='';
            isnegative=1;
        else
            isnegative=0;
        end
    
        out=Float.intBitsToFloat( Long.parseLong(  binstr  , 2) );
        if isnegative
         out=-out;
        end
    
    end
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

In MATLAB's Image Processing Toolbox there's the improfile function that returns the intensity profile
I have a matlab function that returns results in a uitable. There are 2
Is there a command in MATLAB that allows me to find all NaN (Not-a-Number)
I know that there is the possibility of Matlab of pausing a Matlab function
Is there a way to combine 2 vectors in MATLAB such that: mat =
In matlab there is a special function which is not available in any of
Is there a keyword in Matlab that is roughly equivalent to None in python?
In R, there is a function locator which is like Matlab's ginput where you
I would like to create a function in Matlab that, given an image, will
my friend write great function that do image processing in matlab (with image processing

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.