We don't bite newbies here... much PerlMonks

### Re^8: How to write testable command line script? (updated)

by thechartist (Monk)
 on Nov 26, 2018 at 17:47 UTC ( #1226374=note: print w/replies, xml ) Need Help??

I agree that this alternate method is correct; my question now is if my transliteration of his base 60 algorithm has flaws that I did not initially see. I want to make an argument that these are 2 separate ways of describing the same point, but I do not have a proof yet.

• Comment on Re^8: How to write testable command line script? (updated)

Replies are listed 'Best First'.
Re^9: How to write testable command line script? (updated)
by AnomalousMonk (Bishop) on Nov 26, 2018 at 21:19 UTC
... these are 2 separate ways of describing the same [angle] ...

There are an infinite number of ways to describe any angle. I see nothing inherently wrong with representing -0° 1' 0" (or 0°, -1', 0" in a different notation) as  (-1, 59, 0) internally as long as this tuple (and all such "weird" tuples; there are many in the test sets) correctly reduce to whatever you define as a "standard" representation (and the aforementioned tuple does reduce to  (0, -1, 0) as shown below). In the end, it's all a matter of the constraints you choose to impose on, e.g., notation and internal representation, user input, user output, etc., etc. These are all programmer choices.

```c:\@Work\Perl\monks\thechartist>perl -wMstrict -le
"use TrigCalc qw(reduce);
;;
my @dms = reduce(-1, 59, 0);
print qq{(@dms)};
"
(0 -1 0)
That said, simplest is usually best, so my choice for the internal representation of this angle would be -60 arc-seconds (or maybe decimal degrees, or radians, or whatever).

Give a man a fish:  <%-{-{-{-<

Thanks for coming back to this. I was about to go into detail showing how my representation, at least for the purposes of addition and subtraction, was equivalent, but you had already done that for me.

After starting this script, I later realized that my initial algorithm did not handle division correctly. I believe you method of converting everything to seconds is the most general and will likely be what I implement when I revise this.

Create A New User
Node Status?
node history
Node Type: note [id://1226374]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others exploiting the Monastery: (3)
As of 2020-10-28 03:25 GMT
Sections?
Information?
Find Nodes?
Leftovers?
Voting Booth?
My favourite web site is:

Results (259 votes). Check out past polls.

Notices?