• Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint
Share this Page URL
Help

Chapter 14. Working with Numbers: The Ma... > How JavaScript Handles Numbers

How JavaScript Handles Numbers

It's a rare (although probably sane) JavaScript programmer who never has to deal with numbers. Most of us have to cobble together scripts that process order totals, generate sales taxes and shipping charges, calculate mortgage payments, and perform other number-crunching duties. To that end, it must be said that JavaScript's numeric features aren't the greatest in the programming world, but there are plenty of features to keep most scripters happy. This chapter tells you about those features, with special emphasis on the Math object.

The first thing you need to know is that JavaScript likes to keep things simple, particularly when it comes to numbers. For example, JavaScript is limited to dealing with just two numeric data types: integers—numbers without a fractional or decimal part, such as 1, 759, and -50—and floating-point numbers—values that have a fractional or decimal part, such as 2.14, 0.01, and -25.3333.


PREVIEW

                                                                          

Not a subscriber?

Start A Free Trial


  
  • Creative Edge
  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint