Quantcast
Channel: Windows PowerShell forum
Viewing all articles
Browse latest Browse all 21975

Powershell didn’t pay attention in mathematics!?

$
0
0

Hi All,

a short PS question witch I can’t explain.

#########################################################

$myA="0.40"

$myB="1.03"

$myA= ([double]($myA))

$myB= ([double]($myB))

$mySum=$myA+$myB

$mySum|Export-ClixmlC:\Temp\test1.xml -EncodingUTF8

#########################################################

#Export in File = <Db>1.4300000000000002</Db>

#########################################################

#########################################################

$myA="0.40"

$myB="1.02"

$myA= ([double]($myA))

$myB= ([double]($myB))

$mySum=$myA+$myB

$mySum|Export-ClixmlC:\Temp\test2.xml -EncodingUTF8

#########################################################

#Export in File = <Db>1.42</Db>

#########################################################

Why the F* is 0.40 + 1.03 = 1.4300000000000002
The value in PS is correct -> only if I exported them to XML the value is incorrect and only for 1.43?

Is there some “Feature” I don’t know? Can someone explain this to me?

Many thanks in advance.

Kind regards
David


Viewing all articles
Browse latest Browse all 21975

Trending Articles