Does +00 degrees = -00 degrees ?

0 views
Skip to first unread message

John Murrell

unread,
Aug 11, 2015, 4:41:47 PM8/11/15
to alta...@googlegroups.com

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

 

J R

unread,
Aug 12, 2015, 3:30:17 AM8/12/15
to alta...@googlegroups.com
John

The problem doesn't really seem to be one of dealing with minus zero but one of not recognising that the minus sign applies to all components of the coordinate.  

The negative sign is the representation of the convention that it means south of the (celestial) equator, ditto east and west.  All the components, not just the first, are negative.  

A negative coordinate might be better written as a vector having magnitude and direction eg

[-dd,-mm,-ss] or usually as -1.[dd,mm,ss]

and then the is no problem performing arithmetic operations.  

For instance the distance from 'A' to 'B' in your example is 

[0,30,0] minus [0,-30,0]     with no need for minus zero

and the answer is [0, 30-(-30], 0] = [0,60,0]

The distance from 'B' to 'A' is 

[0,-30,0] minus [0,30,0]

and the answer is 

[0, (-30 - 30), 0 = [0,-60,0]

In the first case the vector distance is 60 minutes going (say) North to South, and in the second case the vector distance is 60 minutes going South to North.  The distance element of the vector subtraction is commutative so that A to B is the same physical distance as B to A, just in the other direction.

Computationally if the program can't handle such vector conventions the solution is to decimalise the vector as you say, or convert everything to a common unit which is a signed scalar, eg

[2d,23m,08s] = [2x60x60 plus 23x60 plus 08] = 8588 seconds if North and -8588 seconds if South.  Then compute away.  (Of course it is common to describe the seconds element in the coordinate vector as a decimal, eg 8.6 seconds and that doesn't help anyone!)

There is a nice and I think exact analogy which would have rooted this out long since had the Victorians invented both the credit card and electronic computers.  Being virtuous Victorians our monthly credit card would have read

Balance carried forward      £1/6/3   One pound six and thruppence 
Payment received               £1/6/3

Balance owing                     £0

None of us, not least Q Vic, would have been too amused had this been calculated as £2/12/6 owing.  Here the accounting convention is that a cash balance is a debit item ie the payment received is a negative and the starting debt is treated a positive.  Goes against intuition to think of cash in hand as a debit but we accept it with no qualms at all in credit card statements as they take the perspective of us being debtors.

regards

James


Sent from my iPad
--
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.

John Murrell

unread,
Aug 12, 2015, 3:47:31 AM8/12/15
to alta...@googlegroups.com

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

J R

unread,
Aug 12, 2015, 4:09:47 AM8/12/15
to alta...@googlegroups.com
John

Aha!  So some time before AI goes conscious then!

regards

James

Sent from my iPad

Graeme Coates

unread,
Aug 12, 2015, 5:21:59 AM8/12/15
to alta...@googlegroups.com

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:

Graeme Coates

unread,
Aug 12, 2015, 5:22:21 AM8/12/15
to alta...@googlegroups.com

Mike Ross

unread,
Aug 12, 2015, 6:13:30 AM8/12/15
to alta...@googlegroups.com
A couple of clarifications:

binary 11111111 can be interpreted as -1, never -0. In the days before Microsoft, when IBM ruled the world, IBM mainframes calculated using

1) binary with 2 or 4 byte words, where the high order bit of the first byte contained binary 0 for + or 1 for -. In which case (let's start using Hex for this, it's easier) X'FFFFFFFF' and X'FFFF' were -1. 

2. Packed Decimal aka Comp(utational)-3 or Internal Decimal, where each half byre could contain X'0' to X'9' with the last half byte containing the sigh, X'D' for negative numbers and X'F' or X'C' for positives, although X'B' for negatives and X'A' and X'E' for positives were allowed as non-standard. Other computer manufacturers implemented the IBM standard but sometimes allowing the number to be defined as unsigned with the last half digit containing a number (Burroughs did this).

3) Short Floating Point and Long Floating Point formats, that I learnt about in 1966 at the start of my career in commercial IT but have never seen used in business since.

In the days before decimalisation, all sterling amounts were stored in pence and only converted to lsd on output, which in those days meant printed. The only other case when lsd was used internally was in payroll programs in the days when generally people received their money as cash when the computer had to calculate how many pennies, sixpences, florins etc would have to be collected from the bank prior to payday.

Regards Mike 

John Murrell

unread,
Aug 12, 2015, 7:13:19 AM8/12/15
to alta...@googlegroups.com

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 !  

J R

unread,
Aug 12, 2015, 8:35:49 AM8/12/15
to alta...@googlegroups.com
Mike

Fascinating about having to calculate the number of 6d s etc required.  I imagine whoever used to do it by hand was rather proud of the way they never ran out of the right cash on pay day.

In this case, why do something probably just plain wrong (reciprocal of negative infinity notwithstanding).  Instead just compute using the LSD method, decimalise the coordinate, transform it to radians or some such, or apply matrix arithmetic.

If Astro-physics equipment can't cope I now know why my Celestron GOTOs are always out.  Worse than the year 2000 that negative zero.

best wishes

James

Sent from my iPad
Reply all
Reply to author
Forward
0 new messages