Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / fpc-pascal / 2004-08

Re: How to convert between double and extended? (Mattias Gaertner)

6 messages · 3 people ·

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Dr. Rolf Jansen
Where can I get information about the i386 extended and the ppc double format? Is it correct, that the ppc double is simply a reversed i386 double?

I don´t know about the i386 format. In the past I did extended conversions between i386 and M68k. It was simply done by reversing the ten bytes. So, I assume that the the same holds for double conversion between i386 and PPC too, since the double format of PPC and M68k is exactly the same.

For PowerPC you find a description of the format at the following page:

http://developer.apple.com/documentation/mac/PPCNumerics/PPCNumerics -18.html

which is part of a comprehensive description of the PPC Numerics in Apples documentation:

http://developer.apple.com/documentation/mac/pdf/PPC_Numerics.sit.hqx

A more generic description of the PowerPC can be found here:

http://www-3.ibm.com/chips/techlib/techlib.nsf/techdocs/ 852569B20050FF778525699600719DF2/$file/6xx_pem.pdf

You will find the desired information at page 110.

I suggest to reverse the byte at the PPC side, and to "stream" the doubles to the i386 box, and to assign the double there to an extended variable. In this case there is no need for a special conversion routine between double and extended since this is handled by the math co-processor automatically.

Best regards

Rolf

__ InstantWare ______________________________________________________ Dr. Rolf Jansen * Stephanienstraße 19 * D-76133 Karlsruhe * Germany

http://InstantWare.bei.t-online.de/
_____________________________________________________________________

Mattias Gaertner
to Dr. Rolf Jansen
Show quoted text 29 lines
On Sun, 15 Aug 2004 03:03:08 +0200 Mattias Gaertner wrote: > Where can I get information about the i386 extended and the ppc double > format? Is it correct, that the ppc double is simply a reversed i386 > double? I don´t know about the i386 format. In the past I did extended conversions between i386 and M68k. It was simply done by reversing the ten bytes. So, I assume that the the same holds for double conversion between i386 and PPC too, since the double format of PPC and M68k is exactly the same. For PowerPC you find a description of the format at the following page: http://developer.apple.com/documentation/mac/PPCNumerics/PPCNumerics -18.html which is part of a comprehensive description of the PPC Numerics in Apples documentation: http://developer.apple.com/documentation/mac/pdf/PPC_Numerics.sit.hqx A more generic description of the PowerPC can be found here: http://www-3.ibm.com/chips/techlib/techlib.nsf/techdocs/ 852569B20050FF778525699600719DF2/$file/6xx_pem.pdf You will find the desired information at page 110.

Thanks for the hints. That helped.

Show quoted text 5 lines
I suggest to reverse the byte at the PPC side, and to "stream" the doubles to the i386 box, and to assign the double there to an extended variable. In this case there is no need for a special conversion routine between double and extended since this is handled by the math co-processor automatically.

The problem is a binary stream format coming from the i386 object pascal world, using extended and single, but no doubles. So I must be able to create and read i386 10 bytes extended. It's ok to loose some precision.

Mattias

Florian Klaempfl
to Mattias Gaertner
Mattias Gaertner wrote 10 lines
>I suggest to reverse the byte at the PPC side, and to "stream" the >doubles to the i386 box, and to assign the double there to an extended >variable. In this case there is no need for a special conversion >routine between double and extended since this is handled by the math >co-processor automatically. The problem is a binary stream format coming from the i386 object pascal world, using extended and single, but no doubles. So I must be able to create and read i386 10 bytes extended. It's ok to loose some precision.

Shall I write some code?

Mattias Gaertner
to Florian Klaempfl
Show quoted text 13 lines
Mattias Gaertner wrote: >>I suggest to reverse the byte at the PPC side, and to "stream" the >>doubles to the i386 box, and to assign the double there to an extended >>variable. In this case there is no need for a special conversion >>routine between double and extended since this is handled by the math >>co-processor automatically. > > > The problem is a binary stream format coming from the i386 object pascal > world, using extended and single, but no doubles. So I must be able to > create and read i386 10 bytes extended. It's ok to loose some precision. Shall I write some code?

Is this a trick question? :)

Mattias

Florian Klaempfl
to Mattias Gaertner
Mattias Gaertner wrote 21 lines
On Sun, 15 Aug 2004 12:27:10 +0200 Florian Klaempfl wrote: >Mattias Gaertner wrote: > >>>I suggest to reverse the byte at the PPC side, and to "stream" the >>>doubles to the i386 box, and to assign the double there to an extended >>>variable. In this case there is no need for a special conversion >>>routine between double and extended since this is handled by the math >>>co-processor automatically. >> >> >>The problem is a binary stream format coming from the i386 object pascal >>world, using extended and single, but no doubles. So I must be able to >>create and read i386 10 bytes extended. It's ok to loose some precision. > >Shall I write some code? Is this a trick question? :)

No. It was an offer :) I was only asking because I guess I've some experience with messing with floats :)

Mattias Gaertner
to Florian Klaempfl
Show quoted text 28 lines
Mattias Gaertner wrote: > On Sun, 15 Aug 2004 12:27:10 +0200 Florian Klaempfl > wrote: > > >>Mattias Gaertner wrote: >> >>>>I suggest to reverse the byte at the PPC side, and to "stream" the >>>>doubles to the i386 box, and to assign the double there to an extended > >>>>variable. In this case there is no need for a special conversion >>>>routine between double and extended since this is handled by the math > >>>>co-processor automatically. >>> >>> >>>The problem is a binary stream format coming from the i386 object >pascal>>world, using extended and single, but no doubles. So I must be >able to>>create and read i386 10 bytes extended. It's ok to loose some >precision.> >>Shall I write some code? > > > Is this a trick question? :) No. It was an offer :) I was only asking because I guess I've some experience with messing with floats :)

Then please start.
In the meantime, I will improve the DefineProperties in the LCL for mac os x.

Mattias