I have the following procedure :
procedure GetDegree(const num : DWORD ; var degree : DWORD ; min ,sec : Extended);
begin
degree := num div (500*60*60);
min := num div (500*60) - degree *60;
sec := num/500 - min *60 - degree *60*60;
end;
After degree variable gets assigned the debugger skips to the end of the procedure . Why is that?
It’s an optimisation. The variables
minandsecare passed by value. That means that modifications to them are not seen by the caller and are private to this procedure. Hence the compiler can work out that assigning to them is pointless. The values assigned to the variables can never be read. So the compiler elects to save time and skip the assignments.I expect that you meant to declare the procedure like this:
As I said in your previous question, there’s not really much point in using
Extended. You would be better off with one of the standard floating point types,SingleorDouble. Or even using the genericRealwhich maps toDouble.Also, you have declared
minto be of floating point type, but the calculation computes an integer. My answer to your previous question is quite precise in this regard.I would recommend that you create a record to hold these values. Passing three separate variables around makes your function interfaces very messy and breaks encapsulation. These three values only have meaning when consider as a whole.