mocart
mocart

Reputation: 615

converting system.object to int32 (powershell)

I have a variable:

$a =37,5 (System.Object[]).

how i can convert it to int32 without fractional part (ex. Round to 38)? Thanks.

Upvotes: 1

Views: 7205

Answers (1)

Anton Krouglov
Anton Krouglov

Reputation: 3399

$a = 37,5 #<-- THIS IS ARRAY
[int]$a_int = [math]::Round($a -join ".")
$a_int

38

$a = 37.5 #<-- THIS IS FLOAT NUMBER
[int]$a_int = [math]::Round($a)
$a_int

38

Upvotes: 3

Related Questions