Board index » delphi » Converting Type - Real(Pascal) to Visual Basic

Converting Type - Real(Pascal) to Visual Basic

I have data base (btrieve), where files where created in Pascal and uses
Real Type (digits 6  decimal-2) and I need to find a way to read these data
by Visual Basic
For example:
Number (33,33) is representing as  ( (134) (31) (133) (235) (81) (5))  or
(?-?Q )
How from byte representation find the number 33.33
Thanks
 

Re:Converting Type - Real(Pascal) to Visual Basic


Quote
Tomek wrote:
> I have data base (btrieve), where files where created in Pascal and uses
> Real Type (digits 6  decimal-2) and I need to find a way to read these data
> by Visual Basic
> For example:
> Number (33,33) is representing as  ( (134) (31) (133) (235) (81) (5))  or
> (?-?Q )
> How from byte representation find the number 33.33
> Thanks

you can't convert them with Pascal to EXTENDED or DOUBLE? Because
EXTENDED or DOUBLE are IEEE compliant types...Real is some proprietary
Borland stuff...

Greetings

Markus

Re:Converting Type - Real(Pascal) to Visual Basic


JRS:  In article <3C6D314A.62666...@yahoo.com>, seen in
news:comp.lang.pascal.ansi-iso, CBFalconer <cbfalco...@yahoo.com> wrote
at Fri, 15 Feb 2002 16:32:39 :-

Quote
>Tomek wrote:

>> I have data base (btrieve), where files where created in Pascal
>> and uses Real Type (digits 6  decimal-2) and I need to find a
>> way to read these data by Visual Basic
>> For example:
>> Number (33,33) is representing as:
>>    ( (134) (31) (133) (235) (81) (5))  or   (?-?Q )
>> How from byte representation find the number 33.33

>Write it out in hex or binary and examine the pattern.  If you are
>lucky you will find it is an IEEE std format.  I don't think you
>understand the makeup of floating point formats from the tone of
>your question, so you would be well advised to read Knuth.

Now if you only knew TurboPascal...  Is there an IEEE 6-byte format??

In <URL:http://www.merlyn.demon.co.uk/programs/>, sixbytes.pas is a
short TP program containing a routine to convert a six-byte real, using
arithmetic, to a number (expressed as a ten-byte Extended, but trivial
to change).

The routine SixToExt takes a "real" argument, and casts it to an array
[1..6] of byte; the argument could trivially be supplied as an array.

TP code is easy enough to read; probably the OP will be able to
translate into his preferred language.

OP: please do not multi-post.

Cross-posted c.l.p.a-i, c.l.p.b; FU c.l.p.b

--
? John Stockton, Surrey, UK.  j...@merlyn.demon.co.uk   Turnpike v4.00   MIME. ?
 Web  <URL:http://www.merlyn.demon.co.uk/> - FAQqish topics, acronyms & links.
 PAS, EXE in  <URL:http://www.merlyn.demon.co.uk/programs/> - see 00index.txt.
 Do not Mail News to me.    Before a reply, quote with ">" or "> " (SoRFC1036)

Re:Converting Type - Real(Pascal) to Visual Basic


Quote
"Tomek" <xx20...@wp.pl> wrote:

> I have data base (btrieve), where files where created in Pascal and uses
> Real Type (digits 6  decimal-2) and I need to find a way to read these data
> by Visual Basic
> For example:
> Number (33,33) is representing as  ( (134) (31) (133) (235) (81) (5))  or
> (?-?Q )
> How from byte representation find the number 33.33
> Thanks

The 'real' type is defined as:

    width in bits
    1                   39                      8
   +-+---------------------------------------+--------+
   |s|                  f                    |  e     |
   +-+---------------------------------------+--------+

and the value v is calculated as:

    if 0 < e <= 255 then v = (-1)^s * 2^(e-129) * (1.f)
    if e = 0 then v = 0

where '^' means power. This comes directly from the "TP6 Programmer's Guide".

Regards, Ren
--
Using Virtual Access
http://www.vamail.com

Re:Converting Type - Real(Pascal) to Visual Basic


I am gradually migrating my apps from TP7 to VB5. The simplest way I have found
to move numeric values from TP to VB is to simply store the data in a text
file. VB can easily read the file and you can write a routine to convert the
text representation to whatever data type you need.

Quote
Tomek wrote:
> I have data base (btrieve), where files where created in Pascal and uses
> Real Type (digits 6  decimal-2) and I need to find a way to read these data
> by Visual Basic
> For example:
> Number (33,33) is representing as  ( (134) (31) (133) (235) (81) (5))  or
> (?-?Q )
> How from byte representation find the number 33.33
> Thanks

--
Val Mehling
va...@earthlink.net

Web Pages
http://home.earthlink.net/~valjm/

XRL (Extreme Racing League) Pics
http://odin.prohosting.com/~valjm

http://odin.prohosting.com/valmeh/

Re:Converting Type - Real(Pascal) to Visual Basic


Quote
Dr John Stockton wrote:

> JRS:  In article <3C6D314A.62666...@yahoo.com>, seen in
> news:comp.lang.pascal.ansi-iso, CBFalconer <cbfalco...@yahoo.com> wrote
> at Fri, 15 Feb 2002 16:32:39 :-
> >Tomek wrote:

> >> I have data base (btrieve), where files where created in Pascal
> >> and uses Real Type (digits 6  decimal-2) and I need to find a
> >> way to read these data by Visual Basic
> >> For example:
> >> Number (33,33) is representing as:
> >>    ( (134) (31) (133) (235) (81) (5))  or   (?-?Q )
> >> How from byte representation find the number 33.33

> >Write it out in hex or binary and examine the pattern.  If you are
> >lucky you will find it is an IEEE std format.  I don't think you
> >understand the makeup of floating point formats from the tone of
> >your question, so you would be well advised to read Knuth.

> Now if you only knew TurboPascal...  Is there an IEEE 6-byte format??

Well, to be fair he said six digits. To tell you the truth, its been a
while since I did 32 bit float, but 6-8 digits might be about right.
I would start by dumping out zero (a floating point zero), and seeing
what that matches.

- Show quoted text -

Quote

> In <URL:http://www.merlyn.demon.co.uk/programs/>, sixbytes.pas is a
> short TP program containing a routine to convert a six-byte real, using
> arithmetic, to a number (expressed as a ten-byte Extended, but trivial
> to change).

> The routine SixToExt takes a "real" argument, and casts it to an array
> [1..6] of byte; the argument could trivially be supplied as an array.

> TP code is easy enough to read; probably the OP will be able to
> translate into his preferred language.

> OP: please do not multi-post.

> Cross-posted c.l.p.a-i, c.l.p.b; FU c.l.p.b

> --
> ? John Stockton, Surrey, UK.  j...@merlyn.demon.co.uk   Turnpike v4.00   MIME. ?
>  Web  <URL:http://www.merlyn.demon.co.uk/> - FAQqish topics, acronyms & links.
>  PAS, EXE in  <URL:http://www.merlyn.demon.co.uk/programs/> - see 00index.txt.
>  Do not Mail News to me.    Before a reply, quote with ">" or "> " (SoRFC1036)

Re:Converting Type - Real(Pascal) to Visual Basic


JRS:  In article <3C6E0DE2.111DB...@moorecad.com>, seen in
news:comp.lang.pascal.borland, Scott Moore <sam...@moorecad.com> wrote
at Fri, 15 Feb 2002 23:44:34 :-

Quote
>I would start by dumping out zero (a floating point zero), and seeing
>what that matches.

Every bit of a normal floating point zero, of whatever type, is zero in
Borland's Pascals & Delphi; I don't know about Kylix.

Some patterns with some bits non-zero may also be interpreted as zero.

In announcing your new WWW address, you also gave the old one.  Few are
so thoughtful; it makes updating much easier.

--
? John Stockton, Surrey, UK.  j...@merlyn.demon.co.uk   Turnpike v4.00   MIME. ?
  <URL:http://www.merlyn.demon.co.uk/> TP/BP/Delphi/&c., FAQqy topics & links;
  <URL:http://www.merlyn.demon.co.uk/clpb-faq.txt> Pedt Scragg: c.l.p.b. mFAQ;
  <URL:ftp://garbo.uwasa.fi/pc/link/tsfaqp.zip> Timo Salmi's Turbo Pascal FAQ.

Other Threads