There has been an interesting discussion in one of the groups I am a member of about converting declinations in the format ±dd mm ss. It appears that Fortran, Python and I think Excel have problems when the field dd is zero. In particular if the dd field is equal to -00 because there is no representation in their number system for -0 so it tends to get treated the same as +0. However -00 30 00 is not the same as +00 30 00, the two positions being a degree apart. This is due to the dd, mm & ss being kept in three separate fields and there being no representation for -00 for the degree field.
There are various work arounds mostly looking for the character + or – at the start of the number however the best solution is to keep the angle as a decimal so one is kept at 0.5 degrees and the other -0.5 degrees.
In Python you can test that the two ‘values’ of zero are the same:
In [1]: +0 == -0
Out[1]: True
Something to think about when working with angles in hh mm ss in various languages .
Regards
John
--
You received this message because you are subscribed to the Google Groups "Altair_B" group.
To unsubscribe from this group and stop receiving emails from it, send an email to altair_b+u...@googlegroups.com.
To post to this group, send email to alta...@googlegroups.com.
Visit this group at http://groups.google.com/group/altair_b.
For more options, visit https://groups.google.com/d/optout.
Hi James,
The problem really stems from the fact that (some ?) computer languages do not understand sexidecimal notation so read and store the data as three separate fields for dd, mm, ss or indeed Pounds, shillings and pence to use your example.
If the degree or pound value is a positive number or a negative number (other than zero) that field will be read in correctly and be saved as a negative or positive integer as appropriate. However +0 = 0 = -0 all three are saved as zero. To read the sign and save it you have to resort to using a text or first character function – that is how I got around it in Excel.
Interestingly the standard for floating point numbers IEEE754 (https://en.wikipedia.org/wiki/IEEE_754-1985 ) does specify how -0 should be stored but not how the programme deals with it. Of course the normal integer and two’s complement integer standard do not include -0 in their number range though I have seen a reference that 11111111 might represent -0 ( 0 is represented as 00000000).
All in all it is far easier to use floating point decimal representation – I presume that is why we changed to decimal currency. It would be fun if all the computer software had to cope with LSD accounting.
Regards
John
I’d be looking to convert to a float for representation in this case I think (in fact – have done in the past for lat long: https://www.chromosphere.co.uk/2015/03/18/eclipse-calculations-using-python/ ;-))
Conversion back is fairly simple if need be – in fact there’s already a library for it:
Darn – missed the link!
Here:
http://pyastronomy.readthedocs.org/en/latest/pyaslDoc/aslDoc/coordinates.html
GC
Mike,
I bow to your superior experience however ‘The widely used two's complement encoding does not allow a negative zero. In a 1+7-bit sign-and-magnitude representation for integers, negative zero is represented by the bit string 1000 0000. In an 8-bit one's complement representation, negative zero is represented by the bit string 1111 1111. In all three encodings, positive zero is represented by 00000000.’ This is from : https://en.wikipedia.org/wiki/Signed_zero .
So some number systems allow for negative zeros – there is then the question of what the language / programme using this representation does with a -0 which is sort of what GC is saying.
In fact the whole problem was introduced to me by a thread in the Astropy mailing list where someone was having problems in reading in a text file with Declination starting -00. It appears that AstroPy does not read this correctly. I had already stumbled on this in Excel in the opposite sense converting decimal negative declinations where the angle was less than one degree. Excel does not like -0 either ( or negative times) so I ended up doing the conversion in positive ‘time’ and then adding the minus as text which was Ok as the spreadsheet was designed to be read by humans !