Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

Thread Subject:
how to convert from binary floating point to decimal?

Subject: how to convert from binary floating point to decimal?

From: Benjamin Blanton

Date: 4 Feb, 2010 15:48:04

Message: 1 of 6

I have data that represented in 32 bit binary floating point ("1000111111100010010000000000000" for example equals x"47F12000" in hex and 123456 in decimal.) I'd like to use matlab to convert my binary string, into a decimal number. I've been told that matlab can do this, but have been unable to figure out how.

Can you help?

Subject: how to convert from binary floating point to decimal?

From: wapo

Date: 4 Feb, 2010 16:13:33

Message: 2 of 6

On Feb 4, 4:48 pm, "Benjamin Blanton" <benjamin.blan...@lmco.com>
wrote:
> I have data that represented in 32 bit binary floating point  ("1000111111100010010000000000000" for example equals x"47F12000" in hex and 123456 in decimal.)  I'd like to use matlab to convert my binary string, into a decimal number.  I've been told that matlab can do this, but have been unable to figure out how.
>
> Can you help?

dec2bin

Subject: how to convert from binary floating point to decimal?

From: Benjamin Blanton

Date: 4 Feb, 2010 16:25:07

Message: 3 of 6

> dec2bin

I'm aware of dec2bin and bin2dec, but my data is represented in floating point. I'm not interested in what "1000111111100010010000000000000" is simply in decimal, It's a binary number representing a floating point:
Sign Exponent Significand
1 8 23 bits

Subject: how to convert from binary floating point to decimal?

From: Walter Roberson

Date: 4 Feb, 2010 17:00:22

Message: 4 of 6

Benjamin Blanton wrote:
>> dec2bin
>
> I'm aware of dec2bin and bin2dec, but my data is represented in floating
> point. I'm not interested in what "1000111111100010010000000000000" is
> simply in decimal, It's a binary number representing a floating point:
> Sign Exponent Significand
> 1 8 23 bits


NumAsFloat32 = typecast( uint32( bin2dec( NumAsString ) ), 'float')

Or maybe it is 'single' instead of 'float'; a pain to check at the moment.

Subject: how to convert from binary floating point to decimal?

From: Benjamin Blanton

Date: 4 Feb, 2010 18:15:23

Message: 5 of 6

Walter Roberson <roberson@hushmail.com> wrote in message <hkeuf6$93u$2@canopus.cc.umanitoba.ca>...
> Benjamin Blanton wrote:
> >> dec2bin
> >
> > I'm aware of dec2bin and bin2dec, but my data is represented in floating
> > point. I'm not interested in what "1000111111100010010000000000000" is
> > simply in decimal, It's a binary number representing a floating point:
> > Sign Exponent Significand
> > 1 8 23 bits
>
>
> NumAsFloat32 = typecast( uint32( bin2dec( NumAsString ) ), 'float')
>
> Or maybe it is 'single' instead of 'float'; a pain to check at the moment.

awesome thanks!

Subject: how to convert from binary floating point to decimal?

From: Balaji

Date: 4 Dec, 2011 10:08:08

Message: 6 of 6

Walter Roberson <roberson@hushmail.com> wrote in message <hkeuf6$93u$2@canopus.cc.umanitoba.ca>...
> Benjamin Blanton wrote:
> >> dec2bin
> >
> > I'm aware of dec2bin and bin2dec, but my data is represented in floating
> > point. I'm not interested in what "1000111111100010010000000000000" is
> > simply in decimal, It's a binary number representing a floating point:
> > Sign Exponent Significand
> > 1 8 23 bits
>
>
> NumAsFloat32 = typecast( uint32( bin2dec( NumAsString ) ), 'float')
>
> Or maybe it is 'single' instead of 'float'; a pain to check at the moment.

Very helpful, that. Thanks much. Surprising MATLAB doesn't have a more direct function to get this.

Tags for this Thread

No tags are associated with this thread.

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

Contact us