It would seem that a simple operation, subtraction, causes problems in PowerShell. Who can explain why:

3.1 - 3 = 0.1

4.1 - 4 = 0.0999999999999996

20.1 - 20 = 0.100000000000001

It would not be desirable to fasten a rounding off, in such simple operation.

    1 answer 1

    Store numbers in decimal . Like this:

     PS C:\> [decimal]3.1 - 3 0.1 PS C:\> [decimal]4.1 - 4 0.1 PS C:\> [decimal]20.1 - 20 0.1 

    The problem you described is a common occurrence for floating-point numbers.

    • The first time I encountered such a problem, thank you - Aleksey