[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[task #15567] Converting hh:mm:ss and dd:mm:ss notations to degrees and
From: |
Mohammad Akhlaghi |
Subject: |
[task #15567] Converting hh:mm:ss and dd:mm:ss notations to degrees and vice vesa |
Date: |
Sat, 14 Mar 2020 17:41:36 -0400 (EDT) |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:74.0) Gecko/20100101 Firefox/74.0 |
Follow-up Comment #8, task #15567 (project gnuastro):
Thanks Katrik. I see so many tests have been added.
To test it independently, I had to remove the `config.h' part and also add a
`main' function:
int
main(void)
{
char *test="2:30:20";
printf("%f\n", gal_units_convert_ra_decimal(test));
printf("%f\n", gal_units_convert_dec_decimal(test));
}
I then gave the first random number that occurred to me: `2:30:20', but I got
the `Invalid length' error! I then changed it to `02:30:20' and got that error
again.
Generally, this type of error checking on the raw string, and manually
checking every number (with the `strtod (copy + 1, ©)' part) is not good
practice: it can hide many bugs.
What I recommend is to use the C library's `strok' function (for GNU C
Library, its explained under the Finding tokens in a string
<https://www.gnu.org/software/libc/manual/html_node/Finding-Tokens-in-a-String.html>
section). You can call it in a loop (so all the values are checked in one
piece of code). You can specify the delimiter with `strtok' to be `:'.
_______________________________________________________
Reply to this item at:
<https://savannah.gnu.org/task/?15567>
_______________________________________________
Message sent via Savannah
https://savannah.gnu.org/
- [task #15567] Converting hh:mm:ss and dd:mm:ss notations to degrees and vice vesa, Mohammad Akhlaghi, 2020/03/03
- [task #15567] Converting hh:mm:ss and dd:mm:ss notations to degrees and vice vesa, Mohammad Akhlaghi, 2020/03/03
- [task #15567] Converting hh:mm:ss and dd:mm:ss notations to degrees and vice vesa, Kartik Ohri, 2020/03/03
- [task #15567] Converting hh:mm:ss and dd:mm:ss notations to degrees and vice vesa, Kartik Ohri, 2020/03/03
- [task #15567] Converting hh:mm:ss and dd:mm:ss notations to degrees and vice vesa, Mohammad Akhlaghi, 2020/03/03
- [task #15567] Converting hh:mm:ss and dd:mm:ss notations to degrees and vice vesa, Kartik Ohri, 2020/03/10
- Message not available
- Message not available
- [task #15567] Converting hh:mm:ss and dd:mm:ss notations to degrees and vice vesa,
Mohammad Akhlaghi <=
- Message not available
- Message not available
- Message not available
- Message not available
- [task #15567] Converting hh:mm:ss and dd:mm:ss notations to degrees and vice vesa, Mohammad Akhlaghi, 2020/03/16
- Message not available
- [task #15567] Converting hh:mm:ss and dd:mm:ss notations to degrees and vice vesa, Kartik Ohri, 2020/03/17
- Message not available
- Message not available
- Message not available
- Message not available
- Message not available
- [task #15567] Converting hh:mm:ss and dd:mm:ss notations to degrees and vice vesa, Mohammad Akhlaghi, 2020/03/18
- [task #15567] Converting hh:mm:ss and dd:mm:ss notations to degrees and vice vesa, Kartik Ohri, 2020/03/20
- Message not available
- Message not available
- [task #15567] Converting hh:mm:ss and dd:mm:ss notations to degrees and vice vesa, Mohammad Akhlaghi, 2020/03/20
- Message not available
- [task #15567] Converting hh:mm:ss and dd:mm:ss notations to degrees and vice vesa, Mohammad Akhlaghi, 2020/03/20
- Message not available
- Message not available
- Message not available
- [task #15567] Converting hh:mm:ss and dd:mm:ss notations to degrees and vice vesa, Mohammad Akhlaghi, 2020/03/21
- [task #15567] Converting hh:mm:ss and dd:mm:ss notations to degrees and vice vesa, Kartik Ohri, 2020/03/21
- [task #15567] Converting hh:mm:ss and dd:mm:ss notations to degrees and vice vesa, Mohammad Akhlaghi, 2020/03/21
- [task #15567] Converting hh:mm:ss and dd:mm:ss notations to degrees and vice vesa, Kartik Ohri, 2020/03/22