Help Converting String Fractions to Doubles

Hello! I’m pretty new to PowerShell, but I can’t find an answer to this.

I’m trying to convert one of my FFmpeg cmd scripts to PowerShell, but I can’t figure this out for the life of me
FFprobe responds to a query with a fraction in string format, how can I get that into a double?

This isn’t possible in the command line, as there’s no floating-point support there, there was a workaround using visual basic scripts.
I was hoping that wasn’t needed in PS, but I can’t find a way to solve this seemingly simple problem.

$string = "15/2"
$double = [double]$string
Write-Host $double

Results in
<p class=“”>Cannot convert value “15/2” to type “System.Double”. Error: “Input string was not in a correct format.” FullyQualifiedErrorId : InvalidCastFromStringToDoubleOrSingle</p>
Is there a way to do this in PowerShell?

“15/2” in your example is a String literal and is not evaluated. In lieu of writing a parser to perform the maths, I would suggest splitting the string on the division operator and then dividing the two numbers.

$string = "15/2"
[double]$double = $string.Split('/')[0]/$string.Split('/')[1]