## Вход

Забыли?

#### вход по аккаунту

код для вставкиСкачать
```It became obvious when working out the logic for the less than operator function
that the choice of storing the angle in degrees, minutes, and seconds (DMS) was
an inferior one. It requires that each denomination component of the angle has to
interact with the other components (e.g. when adding two second components
that exceed 60, a 1 has to be carried to the minutes). Since the program
specification in the book specifically says to use DMS, I decided to convert all
angle (DMS) type parameters to decimal degrees before doing any calculations
(and then back to DMS if necessary). Of course, it would be preferable to just
dump the use of DMS altogether in favor of decimal degrees for internal functions
and storage.
The DMS to decimal conversion function was very straightforward and elegant,
but the decimal to DMS function became a little messy because of Fortran's lack
of an intrinsic function to return the fractional part of a floating-point number.
Generally, the logic for the function revolves around repeatedly splitting the
integer and fractional parts of decimal degree input, assigning the integer part to
the respective DMS output, and multiplying the fractional part by 60. Using these
conversion functions, the overloaded operation functions merely needed to be
wrappers to usher the angle type into native operations.
In the following test runs, the right operand is 45° 30' 30" and the left operand is
user-entered.
Enter an angle in degrees, minutes, and seconds:
0 0 1
Less Than Sum:
45 30' 31" Difference:
45 -30' -29"
Enter an angle in degrees, minutes, and seconds:
45 30 31
Greater Than
Sum:
91 1' 1"
Difference:
0 0' 1"
Enter an angle in degrees, minutes, and seconds:
45 30 30
Equal Sum:
91 1' 0"
Difference:
0 0' 0"
```
1/--страниц
Пожаловаться на содержимое документа