In This Chapter
Examining numeric data types
Using the [Math]::round method to round off numbers
Generating random numbers
Changing a number's data type
Dealing with overflow
Computers big and small have one thing in common: They're excellent number crunchers. Next to strings, numbers probably encompass one the most widely used data types in any programming or scripting language. It's highly unlikely that you're going to use Windows PowerShell to perform massive calculations to conduct weather simulations, but no matter how hard you try, you just won't be able to escape the need to deal with numbers. The need can be something as simple as incrementing a value to control a
for loop or something a bit more complex, such as calculating the probability of winning the lottery.
In this chapter, you use Windows PowerShell to perform many common mathematical operations. Computer are just big calculators after all, so knowing how to take advantage of PSH to make these calculations for you can leave your brain cells to do more productive things, like reading the rest of this book.
I touch on data types in Chapter 5, but now I want to focus on just the numeric data types in Windows PowerShell (which, not surprisingly, are the same as .NET numeric data types). All the numeric data types in Windows PowerShell can be classified in either of two categories: integral and nonintegral data types. ...