update: AnomalousMonk said it way better than I did. Original left for historical purposes.


You've misunderstood. I am claiming you are representing negative angles incorrectly. After the subtraction, if you get -60 seconds, you should have the equivalent of -1min. -1min is represented canonically as -0° 1' 0", not as -1° 59' 0". The answer you list in Re^2: How to write testable command line script? of my $test_7 = [ 0, 0, -60]; my $answer_7 = [-1, 59,  0]; is wrong. Honestly, your format doesn't allow you to use the right answer, unless you know how to get perl to store the "-0" correctly (for example, using text), because it should be my $answer_7 = [-0, 1, 0];.

regarding normal base-10 subtraction, when you subtract 0.1 from 0.0, you do NOT borrow one from the ones column, making it -1; then have 10 in the tenths column, and subtract 1, leaving 9/10ths, or -1.9. 0.0-0.1 is obviously -0.1. What you are claiming in DMS is exactly equivalent to claiming that -60sec is -1° 59' 0".

 0.0        Try borrowing: (0-1=-1).(0+10=10) => (-1).(10)
-0.1                                            -( 0).( 1)
====                                            ==========
-0.1                                             (-1).( 9)  => -1.9

That's nonsensical, so obviously not the right method for subtracting a bigger from a smaller.

To subtract a bigger number (M) from a smaller number (S) to do a difference D=M-S, you have to do -(S-M)=D
So start with the S-M:
 0.1
-0.0
====
 0.1
Then negate the answer
-0.1


The same is true in other bases, like the base 60 of DMS:
 0°00'00"
-0°00'60"
========
??°??'??"

You start by making the bigger the first,
 0°00'60"
-0°00'00"
========
????????
Then simplify the top term and subtract
 0°01'00"
-0°00'00"
========
 0°01'00"

The negate: 
-0°1'0"

However you calculate it, whether you do it in decimal degrees, or in DMS, the only difference between -60s and +60s should be the sign at the beginning. +60s is (0° 1' 0"), and -60s is -(0° 1' 0"), which gets simplified to -0° 1' 0", exactly like -(0.016) gets simplified to -0.016 -- the negative sign is placed next to the most significant digit, but implies the whole result is negative. -0.016deg converts to -(0.016deg + 0/60 + 0/3600) = -(0 + 1/60 + 0/3600) = -(0° 1' 0"). You do not interpret -0.016 = (-0) + (0/10) + (1/100) + (6/1000) -- because that math evaluates to +16/1000, which is wrong. You evaluate -0.016 as -(0.016) = -(0 + 0/10 + 1/100 + 6/1000) = -(16/1000), which is right; or, in the other direction (-16 thousandths) = -(16 thousandths) = -(1 hundredth + 6 thousandths) = -(zero ones + 0 tenths + 1 hundredths + 6 thousandths). In the same way, -60sec = -(60sec) = -(0 + 0/60 + 60/3600) = -(0 + 1/60 + 0/3600) = -(0° 1' 0") = -0° 1' 0". Negative Degress minutes seconds (-x°y'z") is not (-x°) + (y') + (z") = -x + y/60 + z/3600, it is -(x° + y' + z") -(x + y/60 + z/3600).

Have I said this in a way that makes my point more clear?

the resource https://books.google.com/books?id=YRNeBAAAQBAJ&lpg=PR1&dq=Albert%20Klaf's%20Trigonometry%20Refresher&pg=PA12#v=onepage&q&f=false did not show an example when the result is negative. I do not believe you are extending into negative results correctly.

(and linking works just fine to me: click on the LINK icon once you've navigated to the google books page, copy the URL, and paste it here between square brackets, like [https://books.google.com/books?id=YRNeBAAAQBAJ&lpg=PR1&dq=Albert%20Klaf's%20Trigonometry%20Refresher&pg=PA12#v=onepage&q&f=false].


In reply to Re^7: How to write testable command line script? by pryrt
in thread How to write testable command line script? by thechartist

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.