OiO.lk Community platform!

Oio.lk is an excellent forum for developers, providing a wide range of resources, discussions, and support for those in the developer community. Join oio.lk today to connect with like-minded professionals, share insights, and stay updated on the latest trends and technologies in the development field.
  You need to log in or register to access the solved answers to this problem.
  • You have reached the maximum number of guest views allowed
  • Please register below to remove this limitation

Hex to Decimal Conversion - PowerShell 5

  • Thread starter Thread starter RonaDona
  • Start date Start date
R

RonaDona

Guest
For some reason, when converting some values in PowerShell from Hex to Decimal, I get incorrect value.

For example: - Type 0xC0000000 then hit enter, you'll get -1073741824 which is incorrect, the right value is 3221225472. The answer given is the value for the negative Hex number I entered FFFFFFFFC0000000

I thought this could be an interpretation issue so I explicitly asked to convert the value to from Hex to Base10 (Decimal), I still got the same incorrect answer -1073741824:

Code:
[Convert]::ToString(0xc0000000,10)

Why does PowerShell interpret 0xc0000000 as the negative for the Hex number c0000000? am I missing something here?
<p>For some reason, when converting some values in PowerShell from Hex to Decimal, I get incorrect value. </p>

<p>For example:
- Type <code>0xC0000000</code> then hit enter, you'll get <code>-1073741824</code> which is incorrect, the right value is <code>3221225472</code>. The answer given is the value for the negative Hex number I entered <code>FFFFFFFFC0000000</code></p>

<p>I thought this could be an interpretation issue so I explicitly asked to convert the value to from Hex to Base10 (Decimal), I still got the same incorrect answer <code>-1073741824</code>:</p>

<pre><code>[Convert]::ToString(0xc0000000,10)
</code></pre>

<p>Why does PowerShell interpret <code>0xc0000000</code> as the negative for the Hex number <code>c0000000</code>? am I missing something here?</p>
Continue reading...
 

Latest posts

M
Replies
0
Views
1
MusicLovingIndianGirl
M
Q
Replies
0
Views
1
quora question
Q
Top