View Single Post
  #26   Report Post  
Old October 26th 10, 10:28 PM posted to uk.railway,uk.transport.london
Dr J R Stockton[_22_] Dr J R Stockton[_22_] is offline
external usenet poster
 
First recorded activity at LondonBanter: Oct 2010
Posts: 2
Default More Oyster Woes ...

In uk.transport.london message
ernal-september.org, Mon, 25 Oct 2010 17:36:10, Sam Wilson
posted:

In article id,
Dr J R Stockton wrote:

In IEEE-754 floating-point "single" and "Double" number formats. there
is both a +zero and a -zero. They have the same value and compare
equal, ...


As do ones-complement integers (which I assume the IEEE-754 formats use
in some form)...


Never assume when you can Wiki ! They encode the unsigned part of
Numbers as mantissa and exponent, and put a sign bit in front.


... but they are distinguishable, even in languages that do not offer
access to the bit patterns as such.


... though I don't know of any higher-level languages that let you
distinguish between +0 and -0 integers even on hardware that supports
the distinction.


In JavaScript, where Numbers are Doubles, one does it by taking the
reciprocal. Plus infinity and minus infinity are easily told apart.
The internal sign of a Number X (that is not NaN) can be determined by
comparing X + 1/X with a zero. Min(Abs(X+1/X)) = 2, at least for real
numbers.

--
(c) John Stockton, nr London, UK. Turnpike v6.05 MIME.
Web http://www.merlyn.demon.co.uk/ - FAQqish topics, acronyms and links;
Astro stuff via astron-1.htm, gravity0.htm ; quotings.htm, pascal.htm, etc.
No Encoding. Quotes before replies. Snip well. Write clearly. Don't Mail News.