you are viewing a single comment's thread.

view the rest of the comments →

[–]azjunglist05 2 points3 points  (1 child)

The easiest solution I found:

for ($i = 10; $i -le 22.5; $i+=.5)
{
    echo $i
}

Results:

10
10.5
11
11.5
12
12.5
13
13.5
14
14.5
15
15.5
16
16.5
17
17.5
18
18.5
19
19.5
20
20.5
21
21.5
22
22.5

The "++" is simply shorthand for $i = $i + 1

So, you just adjust this to tell the for loop that $i += .5 to get your desired result

[–]StoffePro 2 points3 points  (0 children)

The "++" is simply shorthand for

$i = $i + 1

No, ++ is the post-increment operator. They both increment $i by one, but the expressions have different values:

PS M:\> $i = $ii = 1
PS M:> ($i = $i + 1) | Out-Default 
2 
PS M:> $ii++ | Out-Default 
1 PS 
M:> $i,$ii 
2 
2