When one zero is just not enough: JavaScript’s two zeros

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

When one zero is just not enough: JavaScript’s two zeros

Owen Densmore
Administrator
This series on numerics is both useful and entertaining!  Believe it or not, JS has +/- 0.
   
http://www.2ality.com/2012/03/signedzero.html
It may seem weird but it does come up in some cases.

A possibly more important part of the series is just what IS an integer in JS.  Most of us consider it a 32 bit integer but that's not the case:


   -- Owen


============================================================
FRIAM Applied Complexity Group listserv
Meets Fridays 9a-11:30 at cafe at St. John's College
to unsubscribe http://redfish.com/mailman/listinfo/friam_redfish.com
Reply | Threaded
Open this post in threaded view
|

Re: When one zero is just not enough: JavaScript’s two zeros

Gary Schiltz-4
Wow, obviously not one of the "Good Parts" that Crockford refers to:-)

Gary

On Oct 5, 2013, at 11:18 AM, Owen Densmore <[hidden email]> wrote:

This series on numerics is both useful and entertaining!  Believe it or not, JS has +/- 0.
   
http://www.2ality.com/2012/03/signedzero.html
It may seem weird but it does come up in some cases.

A possibly more important part of the series is just what IS an integer in JS.  Most of us consider it a 32 bit integer but that's not the case:


   -- Owen


============================================================
FRIAM Applied Complexity Group listserv
Meets Fridays 9a-11:30 at cafe at St. John's College
to unsubscribe http://redfish.com/mailman/listinfo/friam_redfish.com
Reply | Threaded
Open this post in threaded view
|

Re: When one zero is just not enough: JavaScript’s two zeros

Owen Densmore
Administrator
Lots of folks don't know about JS's numbers being 64 bit IEEE floating point.  JS wanted a single numeric type that "just works" which it mainly does.

With new TypedArrays, traditional numeric types are available too, but takes some hacking to use them correctly as numbers rather than arrays.


On Sat, Oct 5, 2013 at 12:28 PM, Gary Schiltz <[hidden email]> wrote:
Wow, obviously not one of the "Good Parts" that Crockford refers to:-)

Gary

On Oct 5, 2013, at 11:18 AM, Owen Densmore <[hidden email]> wrote:

This series on numerics is both useful and entertaining!  Believe it or not, JS has +/- 0.
   
http://www.2ality.com/2012/03/signedzero.html
It may seem weird but it does come up in some cases.

A possibly more important part of the series is just what IS an integer in JS.  Most of us consider it a 32 bit integer but that's not the case:


   -- Owen


============================================================
FRIAM Applied Complexity Group listserv
Meets Fridays 9a-11:30 at cafe at St. John's College
to unsubscribe http://redfish.com/mailman/listinfo/friam_redfish.com


============================================================
FRIAM Applied Complexity Group listserv
Meets Fridays 9a-11:30 at cafe at St. John's College
to unsubscribe http://redfish.com/mailman/listinfo/friam_redfish.com