Hi, On Tue, 02 Nov 2010 23:49:03 +0100, Bo Berglund <bo.bergl...@gmail.com> wrote: > On Tue, 02 Nov 2010 22:53:21 +0100, Vinzent Höfler > <jellyfish.softw...@gmx.net> wrote: > >>On Tue, 02 Nov 2010 21:39:31 +0100, Felipe Monteiro de Carvalho >><felipemonteiro.carva...@gmail.com> wrote: >> >>> On Tue, Nov 2, 2010 at 7:04 PM, Bo Berglund <bo.bergl...@gmail.com> >>> wrote: >>>> Thanks, that helps a lot! Are there also overloaded BEtoN functions >>>> for floating point values? >>> >>> I think that single and double have always the same binary layout. >> >>Mostly, I'd guess. But I wouldn't count on that. >> > I know for sure that on the Motorola system the floats are 4 bytes > (single precision) and have to be swapped in order to be used on > Windows. I have done it on Delphi already so I know this is a fact. > So now I need to find an endian corrector working with floating point > values as well...
Coming back to the suggestion from jonas: function BEtoN(const AValue : single) : single; type TData = packed record case integer of 0 : (s : single); 1 : (l : longint); end; var d : TData; begin d.s := AValue; d.l := system.BEtoN(d.l); result := d.s; end; A BEtoN function for doubles is similar, just replace the single type by double, and longint by int64. Hth, Thomas _______________________________________________ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal