On Wed, 03 Nov 2010 10:50:10 +0100, Thomas Schatzl
<tom_at_w...@gmx.at> wrote:

>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.
>

Hmm,
what would happen if I do this instead:

function BEtoN(const AValue: single): single;
begin
  result := single(BEtoN(longint(AValue)));
end;

I.e. I use typecasting to get the compiler to treat the same 4 bytes
in different ways inside the expression....
Is this legal in FPC?
(I can't test now because I am at work with no FPC system installed)

-- 

Bo Berglund
Developer in Sweden

_______________________________________________
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal

Reply via email to