How do i stop numbers being rounded up and changing in powershell for example
[int]$i = 0.0000085
showing as being 0 but i want to keep it as 0.0000085 so i can add and subtract the number etc.
As explained in Steven comment you are forcing the number to be an integer
which by definition holds whole numbers only and that is why it's loose the precision, remove the cast for int
and powershell will cast it automatically or cast to decimal
instead, see an example:
$i = 0.0000085
$i
8.5E-06
$i.GetType().Name
Double
[int]$i = 0.0000085
$i
0
$i.GetType().Name
Int32
[decimal]$i = 0.0000085
$i
0.0000085
Also, if the number is not intend for any math operation, you can use string as well
$i = "0.0000085"
$i
0.0000085