View Single Post
  #31   Report Post  
Old October 29th 10, 10:33 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, Thu, 28 Oct 2010 17:35:20, Sam Wilson
posted:

In article id,
Dr J R Stockton wrote:


...



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.


Yeah, but you can't say something like

if (result == +0)
{
...
}
else if (result == -0)
{
...
}

can you?

Sam

and have it operate differently from



In JavaScript, float +0 and -0 are arithmetically equal in value, but
their reciprocals differ. Integer operations are 32-bit 2's complement;
+0 & -0 convert to the same Hex value, 00000000. It's all in ECMA 262
5th Edn, free PDF.

--
(c) John Stockton, nr London UK. IE8 FF3 Op10 Sf5 Cr7
news:comp.lang.javascript FAQ http://www.jibbering.com/faq/index.html.
http://www.merlyn.demon.co.uk/js-index.htm jscr maths, dates, sources.
http://www.merlyn.demon.co.uk/ TP/BP/Delphi/jscr/&c, FAQ items, links.