From: Oleg Komarov on
"James Tursa" <aclassyguy_with_a_k_not_a_c(a)hotmail.com> wrote in message <i1g7vl$4h3$1(a)fred.mathworks.com>...
> "James Tursa" <aclassyguy_with_a_k_not_a_c(a)hotmail.com> wrote in message <i1g1u0$g2l$1(a)fred.mathworks.com>...
> > dpb <none(a)non.net> wrote in message <i1g0ar$hfh$1(a)news.eternal-september.org>...
> > >
> > > <http://support.microsoft.com/kb/42980>
> > >
> > > for the MBF tutorial.
> >
> > That was a very useful link, in which it is stated:
> >
> > Sign Bits Exponent Bits Mantissa Bits
> > --------- ------------- -------------
> > IEEE 1 11 52 + 1 (Implied)
> > MBF 1 8 56
> >
> > So it looks like MBF does *not* have a hidden leading mantissa bit. Bottom line is the 'VAXD' options stuff will not work with this format as is. So custom code will be required. However, it should be fairly easy to modify the custom 'VAXD' code to work with this.
>
> But now that I look at it again, it is confusing. 1 + 8 + 56 = 65. This doesn't add up to 64, so something is wrong with the description. Maybe the 56 should have been 55 + 1 ?? I need to find a more descriptive link ...
>
> James Tursa

In this blog the explanations match my case: single float MBF to IEEE 754.
http://www.boyet.com/Articles/MBFSinglePrecision.html

Oleg
From: Oleg Komarov on
> In this blog the explanations match my case: single float MBF to IEEE 754.
> http://www.boyet.com/Articles/MBFSinglePrecision.html
>
> Oleg

But I still don't get it.
I use fread(fid, 4, 'uint32') and it gives me a 4 by 1 array of uint32 values.

Should I use fread(fid, 4, 'uint8') instead?

How can I merge the array into a single number, at least theoretically?

Oleg
From: us on
"Oleg Komarov" <oleg.komarovRemove.this(a)hotmail.it> wrote in message <i1hoqt$e55$1(a)fred.mathworks.com>...
> > In this blog the explanations match my case: single float MBF to IEEE 754.
> > http://www.boyet.com/Articles/MBFSinglePrecision.html
> >
> > Oleg
>
> But I still don't get it.
> I use fread(fid, 4, 'uint32') and it gives me a 4 by 1 array of uint32 values.
>
> Should I use fread(fid, 4, 'uint8') instead?
>
> How can I merge the array into a single number, at least theoretically?
>
> Oleg

a hint:
- did you try...

help typecast;

us
From: Oleg Komarov on
> a hint:
> - did you try...
>
> help typecast;
>
> us

Thanks for the hint!

Now what I do is:

input = double(typecast(fread(fid,4,'*uint8'),'uint32'));

output = bitset(bitand(input,16777215),24)...
..*(power(2,(bitshift(bitand(input,4278190080),-24)-152)))...
..*(input~=0).*(((bitget(input,24)==0)*2)-1)

output =
960628

Which is what I was looking for: YYMMDD --> 96/06/28 --> 1996 may 28

One last question...is there any good reference to understand the conversion outlined above?? I read a lot of stuff on the internet but my knowledge is messy...

Thank you for support

Oleg
From: dpb on
Oleg Komarov wrote:
....

> Which is what I was looking for: YYMMDD --> 96/06/28 --> 1996 may 28

That would be June 28, 1996 in these here parts... :)

> One last question...is there any good reference to understand the
> conversion outlined above?? I read a lot of stuff on the internet but my
> knowledge is messy...
....

I don't know what to suggest other than again

doc bitshift % and friends

The description of each operator seems pretty straightforward to me.

One thing I'd recommend to make parsing the above conversion somewhat
easier would be to print/display the coefficients (like 4278190080) as
hex or binary numbers.

doc sprintf % '%x' might be of interest...???

--