# Category : BASIC Source Code

Archive : QBFAQR01.ZIP

Filename : MBF2NUM.QRM

Ä Area: R-QBasic ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ

Msg#: 13834 Date: 07-30-92 03:33

From: Nick Dyer Read: Yes Replied: No

To: Robert Laszko Mark:

Subj: Numeric conversion help

ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ

RL>

RL>I'm writing a routine to display the number of active records in a

RL>given PCBoard message base file. According to PCBoard's file format

RL>this number is contained in bytes 8 through 11, stored as a Basic S

RL>Precision Real Number. Problem is .... I don't know how to convert

RL>these four bytes into a usable, decimal equivalant.

I think you will find that the following will help if you use Basic

If the 4 byte Basic Real is stored in a string say A$ then,

Q&=CVSMBF(A$)

will place in variable Q& the converted value.

RL>

RL>So what now, coach?? ..... What I'm NOT looking for is the name of

RL>C or Pascal function to do the conversion (but if that's all you ha

RL>I'll take it 🙂 ). I'm using a higher-level language to manipulate

Michael Stewart showed me this technique:

Sub MsFloatToLong (MsFloat As String, L1 As Long)

I1& = Asc(Mid$(MsFloat$, 1))

I2& = Asc(Mid$(MsFloat$, 2))

I3& = Asc(Mid$(MsFloat$, 3))

I4& = Asc(Mid$(MsFloat$, 4))

L1& = ((I1& + (I2& * 256) + (I3& * 65536)) Or &H800000) / (2 ^ (24 -

(I4& - &H80)))

End Sub

Calling the above sub passing the variables containing the four byte basic

real string and a receiving long integer variable will carry out the

conversion necessary.

An unsung hero did this in C, (Author Unknown)

Unsigned long mbf_to_int (m1,m2,m3,exp)

unsigned int m1,m2,m3,exp;

{

return (((m1 + ((unsigned long) m2 << 8) + ((unsigned long) m3 <<

16)) | 0x800000L) >> (24 - (exp - 0x80)));

}

I hope all this helps you. Good Luck!!

Regards

Nick Dyer [email protected]

-!-

þ Orator V1.0 #1þ Mom looted LA & all I got was this lousy tagline.

PCRelay:ALMAC -> #1598 RelayNet (tm)

4.11 ALMAC PC Board BBS +44 (0)324-665371

Very nice! Thank you for this wonderful archive. I wonder why I found it only now. Long live the BBS file archives!

This is so awesome! 😀 I’d be cool if you could download an entire archive of this at once, though.

But one thing that puzzles me is the “mtswslnkmcjklsdlsbdmMICROSOFT” string. There is an article about it here. It is definitely worth a read: http://www.os2museum.com/wp/mtswslnk/