This blog is part of a series that shows example PowerShell code for those learning the language.
This time we’re using PowerShell to find some very small and very large floating point numbers. The principal here is that if you keep dividing a number by 2, there will be a point where the number is so small that you get zero when you divide it. In a similar fashion, if you keep multiplying a number by 2, there will be a point that the number is so large that it’s considered to be “infinity”.
This example shows details about the differently floating point data types ([single] and [double]) and also shows the use of while loops.
You might want to remove the comment on the “Write-Host $last1” line to show the progression to the final number in each example.
# PowerShell lessons cls # Minimum using the [double] data type [double] $last1 = 1 # Minimum using the [single] data type [single] $last1 = 1 # Maximum using the [double] data type [double] $last1 = 1 # Maximum using the [single] data type [single] $last1 = 1 # |