Converting VBScript's CDbl Function

Windows PowerShell

Definition: Returns an expression that has been converted to a Variant of subtype Double.


The double data type “contains a double-precision, floating-point number in the range -1.79769313486232E308 to -4.94065645841247E-324 for negative values; 4.94065645841247E-324 to 1.79769313486232E308 for positive values.”


If it turns out you need a double-precision, floating-point number like that you can use Windows PowerShell to convert a variable to the double data type. The following two commands assign a string value to the variable $a, then convert $a to the double data type:

$a = "11.45"
$a = [double] $a

If you run these two commands and then use the GetType() method against $a you should get back the following information:

IsPublic IsSerial Name
-------- -------- ----
True     True     Double

Return to the VBScript to Windows PowerShell home page