Thread Subject: What is a "floating-point integer representation"?

Subject: What is a "floating-point integer representation"?

From: Schroen Schreiter

Date: 24 Sep, 2009 10:09:02

Message: 1 of 7

Seriously, I don't get it. Found in the help for "hex2dec": http://www.mathworks.com/access/helpdesk/help/techdoc/index.html?/access/helpdesk/help/techdoc/ref/hex2dec.html&http://www.google.nl/search?hl=en&client=firefox-a&rls=org.mozilla%3Aen-US%3Aofficial&hs=Y0Q&num=100&q=%22floating-point+integer+representation%22&btnG=Search

Regards

Subject: What is a "floating-point integer representation"?

From: Rune Allnor

Date: 24 Sep, 2009 10:18:39

Message: 2 of 7

On 24 Sep, 12:09, "Schroen Schreiter" <t.schrei...@tudelft.nl> wrote:
> Seriously, I don't get it.

One possible interpretation:

The integer representation of a floating point bit-pattern.

One possible explanation to the (dubious) interpretation:

An FP number is represented as a number of bits. This pattern
of bits can be represented as an integer number (through a
type-cast to unsigned integer), which in turn can be printed
as a decimal number.

Rune

Subject: What is a "floating-point integer representation"?

From: TideMan

Date: 24 Sep, 2009 10:35:41

Message: 3 of 7

On Sep 24, 10:09 pm, "Schroen Schreiter" <t.schrei...@tudelft.nl>
wrote:
> Seriously, I don't get it. Found in the help for "hex2dec":http://www.mathworks.com/access/helpdesk/help/techdoc/index.html?/acc...
>
> Regards

To paraphrase Lewis Carroll (Through the Looking-Glass):
"When I use a phrase," Humpty Dumpty said in a rather a scornful tone,
"it means just what I choose it to mean – neither more nor less."

Subject: What is a "floating-point integer representation"?

From: Sebastiaan

Date: 24 Sep, 2009 11:05:19

Message: 4 of 7

> To paraphrase Lewis Carroll (Through the Looking-Glass):
> "When I use a phrase," Humpty Dumpty said in a rather a scornful tone,
> "it means just what I choose it to mean – neither more nor less."
Sharp!

I think this would be a nice introduction:
http://en.wikipedia.org/wiki/Double_precision

Basically, every float has a binary representation, and every binary representation can be expressed as a base-10 integer.

The reason for representing a float as an integer is that you can write it to a text file without loosing any significance. (However, make sure that the machines respect the same storage when reading/writing the data between different machines.)

E.g.:
>> pi
ans =
    3.1416 % trimmed float

>> h = num2hex(pi)
h =
400921fb54442d18 % exact hexadecimal representation
>> hex2dec(h)
ans =
   4.6143e+18 % trimmed integer
>> fprintf('%ld\n', hex2dec(h))
4614256656552045568 % exact integer represenation of pi
>> dec2bin(hex2dec(h))
ans =
100000000001001001000011111101101010100010001000010110000000000 % binary representation of pi

Subject: What is a "floating-point integer representation"?

From: Schroen

Date: 24 Sep, 2009 11:37:03

Message: 5 of 7

> I think this would be a nice introduction:
> http://en.wikipedia.org/wiki/Double_precision
>
> Basically, every float has a binary representation, and every binary representation can be expressed as a base-10 integer.
>
> The reason for representing a float as an integer is that you can write it to a text file without loosing any significance. (However, make sure that the machines respect the same storage when reading/writing the data between different machines.)
>
> E.g.:
> >> pi
> ans =
> 3.1416 % trimmed float
>
> >> h = num2hex(pi)
> h =
> 400921fb54442d18 % exact hexadecimal representation
> >> hex2dec(h)
> ans =
> 4.6143e+18 % trimmed integer
> >> fprintf('%ld\n', hex2dec(h))
> 4614256656552045568 % exact integer represenation of pi
> >> dec2bin(hex2dec(h))
> ans =
> 100000000001001001000011111101101010100010001000010110000000000 % binary representation of pi

OK, now I understand where the "floating" part of this expression comes from. However, in the help of the hex2dec function itself is IMO no reference to the float part necessary, since we only operate with a string and an integer.

On the other hand, the result of hex2dec is a double type.
class(hex2dec('ff'))
ans =
double
Maybe that is also a reason the "floating-point integer representation".

Subject: What is a "floating-point integer representation"?

From: Steven Lord

Date: 24 Sep, 2009 13:46:04

Message: 6 of 7


"Schroen Schreiter" <t.schreiter@tudelft.nl> wrote in message
news:h9fgfu$aph$1@fred.mathworks.com...
> Seriously, I don't get it. Found in the help for "hex2dec":
> http://www.mathworks.com/access/helpdesk/help/techdoc/index.html?/access/helpdesk/help/techdoc/ref/hex2dec.html&http://www.google.nl/search?hl=en&client=firefox-a&rls=org.mozilla%3Aen-US%3Aofficial&hs=Y0Q&num=100&q=%22floating-point+integer+representation%22&btnG=Search

The default data type in MATLAB is the double array, a floating-point
format. Some double precision numbers represent noninteger values, like 0.5
and 7.875. Some represent integer values, like 1 and 5. The term
"floating-point integer representation" is just a technical way to refer to
the latter -- double precision numbers whose values are integers. These are
also sometimes called "flints". Note that these are different from values
stored using an integer data type, like int8 or uint32.

--
Steve Lord
slord@mathworks.com
comp.soft-sys.matlab (CSSM) FAQ: http://matlabwiki.mathworks.com/MATLAB_FAQ

Subject: What is a "floating-point integer representation"?

From: Schroen

Date: 24 Sep, 2009 17:32:04

Message: 7 of 7

"Steven Lord" <slord@mathworks.com> wrote in message <h9ft67$6q9$1@fred.mathworks.com>...
>
> The default data type in MATLAB is the double array, a floating-point
> format. Some double precision numbers represent noninteger values, like 0.5
> and 7.875. Some represent integer values, like 1 and 5. The term
> "floating-point integer representation" is just a technical way to refer to
> the latter -- double precision numbers whose values are integers. These are
> also sometimes called "flints". Note that these are different from values
> stored using an integer data type, like int8 or uint32.
>
> --
> Steve Lord
> slord@mathworks.com
> comp.soft-sys.matlab (CSSM) FAQ: http://matlabwiki.mathworks.com/MATLAB_FAQ

Got it, and makes sense. I'd just never heard that expression before.

Thanks a lot.

Greetings
/Schroen

Tags for this Thread

Add a New Tag:

Separated by commas
Ex.: root locus, bode

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.

rssFeed for this Thread

Contact us at files@mathworks.com