Jump to content

Ben Grasset

Members
  • Content Count

    1
  • Joined

  • Last visited

Posts posted by Ben Grasset


  1. Free Pascal's version is just this:

    class operator TPoint.Explicit (apt: TPoint): TSmallPoint;
    begin
      result.x:=apt.x;
      result.y:=apt.y;
    end;

    which simply wraps around if out of range, E.G the following code in FPC:

    program Example;
    
    uses Types;
    
    var 
      PA: TPoint;
      PB: TSmallPoint;
    
    begin
      PA.X := High(SmallInt) + 1;
      PA.Y := Low(SmallInt) - 1;
      PB := TSmallPoint(PA);
      WriteLn(PB.X);
      WriteLn(PB.Y);
    end.

    prints:

    -32768
    32767

    Would this not work in Delphi? I can't recall.

×