Forum Discussion
pratikdarak21
Oct 05, 2023Iron Contributor
Rounding Issue
Hi, In PowerShell, Round (number, 4) method rounding 0.01275 to 0.0128 as 5 decimal having 5. But, 0.48865 not getting rounded to 0.4887 instead it is giving output as 0.4886. What causing p...
LainRobertson
Oct 06, 2023Silver Contributor
You might want to consider casting non-decimal types (double being the most likely default type in PowerShell) to a decimal type (example below) - depending on what the outcome is that you're trying to achieve
Strictly-speaking, this isn't a PowerShell "fault/issue", it's below that as a .NET topic. It just happens to impact PowerShell (along with anything else using .NET).
Cheers,
Lain