Geeks With Blogs
Points To Share Mostly SharePoint

Doug Finke, A PowerShell MVP tested it in .Net where it fails as well. He explained that The call is ambiguous between the following methods or properties: 'System.Math.Floor(decimal)' and 'System.Math.Floor(double)'

My understanding is that PowerShell convert variables as it "pleases". 1/5 will most likely convert to float.

There maybe another approach to doing it w/o the [Math]::Floor. It is the format it with "{0:N0}", then use the D2 format.

$i = 1
$j = "{0:N0}" -f $i/5
$k = "{0:D2}" -f $j

AND IT WORKS!! This is probably better than the [Math]::Floor

That’s All Folks

Posted on Sunday, May 19, 2013 10:59 AM | Back to top


Comments on this post: PowerShell Idiosyncrasy Explained

No comments posted yet.
Your comment:
 (will show your gravatar)


Copyright © PointsToShare | Powered by: GeeksWithBlogs.net