Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
BOOK: Beginning HTML, XHTML, CSS, and JavaScript
This is the forum to discuss the Wrox book Beginning HTML, XHTML, CSS, and JavaScript by Jon Duckett; ISBN: 978-0-470-54070-1
Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: Beginning HTML, XHTML, CSS, and JavaScript section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developersí questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Display Modes
  #1 (permalink)  
Old July 21st, 2010, 09:45 PM
Registered User
 
Join Date: Jul 2010
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Default NaN... is it in the book?

Hi,

I've looked as best I can to find something about NaN in the book, but was unsuccessful. Did I just miss it? Is so, where is it discussed in the book?

Thanks,
Paul
Reply With Quote
  #2 (permalink)  
Old July 22nd, 2010, 07:27 PM
Friend of Wrox
 
Join Date: Jun 2008
Location: Snohomish, WA, USA
Posts: 1,652
Thanks: 3
Thanked 141 Times in 140 Posts
Default

No idea if it's in the book, but if you just want to know what it means:

NaN is actually part of the IEEE specification for floating point numbers. It represents a bit pattern that is impossible in well-formed floating point number.

JavaScript utilizes and extends this meaning and capability: Any time you try to convert a string (or other object type) to a number and the conversion fails (because the string doesn't represent a legal number), the result is marked as NaN.

So, for example:
Code:
var count = parseFloat( "aardvarks" );
will assign the value NaN to the variable count.

JavaScript also provides a convenient way to test if a variable contains the NaN value:
Code:
if ( isNaN(count) ) alert("count is NaN");
And that's about all NaN is used for: An indication that a conversion from string to number failed. It *can* mean a few other (very obscure) things, but I doubt you'll ever encounter them.
Reply With Quote
  #3 (permalink)  
Old July 22nd, 2010, 09:28 PM
Registered User
 
Join Date: Jul 2010
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Thanks for your reply and explanation. I did find information on it elsewhere. (A simple google search got all the information I needed.)

The reason I asked is that I just bought the book and it was the first thing I tried to look up in the book and couldn't find it. That's happened to me before with books -- I try to find something apparently simple in the book and it's not there. Rather disappointing.
Reply With Quote
  #4 (permalink)  
Old July 22nd, 2010, 10:00 PM
Friend of Wrox
 
Join Date: Jun 2008
Location: Snohomish, WA, USA
Posts: 1,652
Thanks: 3
Thanked 141 Times in 140 Posts
Default

You piqued my curiosity. I downloaded all the code for the book and did a scan for "NaN" (case sensitive).

The ONLY place it appears is in code from Chapter 12. And it looks to me like in there, even, the only place it appears is in the various libraries. Such as jquery, MochiKit, scriptaculous, etc.

I agree, this is a little disappointing. I would have expected a book that discusses HTML and JavaScript to have, for example, some basic examples of form validation, including of course the use of parseFloat() and/or parseInt().

Okay, so do a search for parseFloat. Same results.

Even a search for the word function shows very few results outside of chapter 12, and not a one of those that seems to do validation of numeric input. Same with searches for match( and test( which would be used for validation via regular expressions.

Somehow, it doesn't look like this is the book to learn JavaScript from. Might be fine for HTML and CSS, but clearly it doesn't address JavaScript development, at all. Looks like all it does is show you how to use some of the various libraries. Yes?

Okay, finally looked at the Table of Contents. No, this is definitely not a book for learning JavaScript. A few fundamentals in a few pages, and that's all. Can't comment on the HTML and CSS, though the ToC looks like they are covered fairly well. Esp. in comparison to the JS coverage.
Reply With Quote
  #5 (permalink)  
Old July 22nd, 2010, 10:25 PM
Registered User
 
Join Date: Jul 2010
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Thanks. You were much more thorough than I was. As you say, this book isn't much on JavaScript, but hopefully XHTML and CSS are better covered.

Paul
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Is there a NaN in VBA? rahzan Access VBA 11 March 6th, 2016 08:40 AM
NaN elayaraja.s XSLT 2 September 9th, 2008 05:10 AM
NaN spinout ASP.NET 2.0 Basics 4 August 5th, 2007 07:07 AM
Actionscript NaN brainchild Flash (all versions) 1 March 21st, 2007 08:29 AM
format-number NaN rbdave XSLT 1 October 23rd, 2003 07:48 AM



All times are GMT -4. The time now is 05:06 AM.


Powered by vBulletin®
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.