Have noticed the following behaviour when trying to compare two doubles.
Given the following basic script:
[double]$maxValue = 1.5
[double]$startValue = 1.2
[double]$counter = $startValue
while ($counter -lt $maxValue) {
Write-Host $counter
$counter += 0.1
}
Output:
1.2
1.3
1.4
If i change the while statement to use less than or equals: while ($counter -le $maxValue) {
Output:
1.2
1.3
1.4
Which is exactly the same as above and thus missing the expected last value of "1.5" at the end.
How can i properly compare two doubles in powershell?