Tuesday, August 9, 2022

[FIXED] How can I convert a string such as 5.7303333333e+02 to decimal in PowerShell?

Issue

I'm trying to convert strings such as 5.7303333333e+02 to the decimal type. I've tried using [decimal]::TryParse but the return value is false.

Is there a method similar to [datetime]::parseexact, or any clean way to convert these strings? Or am I going to have to parse out the e+02 and do that math separately?


Solution

What about :

[int]"5.7303333333e+02"
[decimal]"5.7303333333e+02"


Answered By - JPBlanc
Answer Checked By - Mildred Charles (PHPFixing Admin)

No comments:

Post a Comment

Note: Only a member of this blog may post a comment.