octave-bug-tracker
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Octave-bug-tracker] [bug #65291] [octave forge] (mapping) degrees2dms p


From: anonymous
Subject: [Octave-bug-tracker] [bug #65291] [octave forge] (mapping) degrees2dms produces incorrect results
Date: Fri, 22 Mar 2024 11:46:30 -0400 (EDT)

Follow-up Comment #14, bug #65291 (group octave):

Thanks for the additional MATLAB output.

Attached is a version of degrees2dms.m along the lines of the first option I
described in comment #11.  Changes compared to the current version at
https://sourceforge.net/p/octave/mapping/ci/default/tree/inst/degrees2dms.m
are as follows:
* Documentation:
        * Specify that the minutes and seconds components will always have 
magnitude
less than 60.
        * Adjust the first example to make everything exact and to demonstrate
fractional seconds.
        * Remove the second example which was incorrect and is now redundant.
        * Simplify and hopefully clarify the explanation of sign handling.
        * Remove the negative sign (which does not seem to be displayed by 
default)
from a zero in the result in the last example.
* Implementation:
        * Reject non-real input.
        * Add special handling for char and logical input to improve 
performance and
clarity.
        * Change the computation of the seconds to improve accuracy.  Output 
should
now match that of MATLAB R2023b for class single, and I suspect it matches for
class double as well.
                * Overflow for large inputs is avoided.
                * Minutes and seconds now depend only on the fractional part of 
the input.
                * Possible issues are avoided by not using the rem function.  
Documentation
for rem claims that "values within a few eps of an integer will be rounded to
that integer before computation for compatibility with MATLAB", but I have
failed to verify this.
        * Update the sign-flipping logic to produce same output as MATLAB 
R2023b, and
hopefully improve clarity.
                * See comment #13 for source of MATLAB behavior.
        * Reject input types not explicitly handled.
                * This might be unreachable currently, but is intended to 
prevent applying
the function to types where it hasn't been validated.  Not sure this is a good
idea.
* Tests:
        * Remove tests enforcing incorrect results.
        * Add tests, including extensive checks of values near transition points
where issues seem most likely.
* Other:
        * Add `## Copyright (C) 2024 The Octave Project Developers` because I am
offering this contribution anonymously.

My offer to provide a more accurate version (the second option I described in
comment #11) still stands.  Please let me know if this is desired.

See also bug #65508 for degrees2dm.m which I just opened.


(file #55881)

    _______________________________________________________

Additional Item Attachment:

File name: degrees2dms.m                  Size:6 KB
    <https://file.savannah.gnu.org/file/degrees2dms.m?file_id=55881>


    AGPL NOTICE

These attachments are served by Savane. You can download the corresponding
source code of Savane at
https://git.savannah.nongnu.org/cgit/administration/savane.git/snapshot/savane-0ba62ed3a038e8b50b65b09fae7f127f4f071c33.tar.gz


    _______________________________________________________

Reply to this item at:

  <https://savannah.gnu.org/bugs/?65291>

_______________________________________________
Message sent via Savannah
https://savannah.gnu.org/




reply via email to

[Prev in Thread] Current Thread [Next in Thread]