Skip to content

Adstring outputs wrong string with negative zero #57

Closed

Description

Adstring outputs the wrong string when dec starts with negative zero (i.e. -0.5), while radec converts correctly.

>> adstring(15, -0.5)
" 01 00 00.0  +00 30 00"

>> radec(15, -0.5)
(1.0, 0.0, 0.0, -0.0, 30.0, 0.0)

The bug seems to be this line in adstring.jl:

dec_string = @sprintf("%+03.2d %02d %s", dec_deg, dec_min, dec_sec_string)

which ignores the negative zero.
A possible fix (although, since I'm a beginner, probably not a reliable one) could be:
dec_string = (dec > 0 ? "+" : "-") * @sprintf("%02.2d %02d %s", abs(dec_deg), dec_min, dec_sec_string)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions