I am writing a PowerShell script that converts a number with a decimal point into an integer.
$val = 1024.24
How to convert this value to integer? (I want it to be 1024)
Use floor rounding, which rounds to the lower whole number
[Math]::Floor($val)
Edit: if just discarding decimal part is not what you are looking for you can use [Math]::Round($val) which will round the number like normal math rounding or you can use [Math]::Ceiling($val) which will round up (in your case it will round to 1025) and it is probably not what you need but it is good to know that you have these options as well.
$val = 1.9 for example, then it is rounded up to $val = 2.0. Does PowerShell have this capability?[Math]::Round($val) I mentioned in the answer[Math]::Round($val) is my solution. (I just saw the edit right now)[int] (or [long], or [decimal], or [bigint], ...) is also an option, but that notably performs half-to-even rounding with .5 values; e.g. [int] 1.5 is 2, but so is [int] 2.5, because the nearest even integer is 2.