This is an optimization. The min and sec variables are passed by value. This means that changes to them are not visible to the caller and are closed to this procedure. Therefore, the compiler may decide that assigning them is pointless. The values ββassigned to variables can never be read. Therefore, the compiler chooses to save time and skip tasks. I expect you to declare a procedure as follows:
procedure GetDegree(const num: DWORD; var degree: DWORD; var min, sec: Extended);
As I said in the previous question, it is not very important to use Extended . You will be better off with one of the standard floating point types, Single or Double . Or even using the generic Real , which maps to Double .
In addition, you declared min for the floating point type, but the calculation evaluates to an integer. My answer to your previous question is pretty accurate in this regard.
I would recommend creating an entry to store these values. Passing three separate variables makes your function interfaces very messy and breaks encapsulation. These three meanings only make sense when considered as a whole.
type TGlobalCoordinate = record Degrees: Integer; Minutes: Integer; Seconds: Real; end; function LongLatToGlobalCoordinate(const LongLat: DWORD): TGlobalCoordinate; begin Result.Degrees := LongLat div (500*60*60); Result.Minutes := LongLat div (500*60) - Result.Degrees*60; Result.Seconds := LongLat/500 - Result.Minutes*60 - Result.Degrees*60*60; end; function GlobalCoordinateToLongLat(const Coord: TGlobalCoordinate): DWORD; begin Result := Round(500*(Coord.Seconds + Coord.Minutes*60 + Coord.Degrees*60*60)); end;
David heffernan
source share