Next: , Previous: , Up: Answers to Exercises   [Contents][Index]

2.7.43 Types Tutorial Exercise 11

There are several ways to insert a calculated number into an HMS form. One way to convert a number of seconds to an HMS form is simply to multiply the number by an HMS form representing one second:

1:  31415926.5359     2:  31415926.5359     1:  8726@ 38' 46.5359"
    .                 1:  0@ 0' 1"              .
                          .

    P 1e7 *               0@ 0' 1"              *

2:  8726@ 38' 46.5359"             1:  6@ 6' 2.5359" mod 24@ 0' 0"
1:  15@ 27' 16" mod 24@ 0' 0"          .
    .

    x time RET                         +

It will be just after six in the morning.

The algebraic hms function can also be used to build an HMS form:

1:  hms(0, 0, 10000000. pi)       1:  8726@ 38' 46.5359"
    .                                 .

  ' hms(0, 0, 1e7 pi) RET             =

The = key is necessary to evaluate the symbol ‘pi’ to the actual number 3.14159...