PxPlus User Forum

Main Board => Discussions => Programming => Topic started by: Breidy on September 10, 2021, 02:31:10 PM

Title: Hexadecimal to Decimal
Post by: Breidy on September 10, 2021, 02:31:10 PM
Hi everyone
I have a question

This formula returns me the decimal number

Excel
HEX2DEC ("8FCB455C") = 2412463452
HEX2DEC ("7FA2478E") = 2141341582

PxPlus
DEC (ATH ("8FCB455C") = -1882503844
DEC (ATH ("7FA2478E") = 2141341582

Why does pxplus return the decimal value of the first data differently?

Could someone guide me please
Title: Re: Hexadecimal to Decimal
Post by: Mike King on September 10, 2021, 03:03:16 PM
As with most computer systems the top (first) bit indicates the sign of the value thus $8FCB455C$ would be a negative number.

If you want to force the value positive regardless of the number of bytes, prefix the value with $00$.

->print DEC (ATH ("008FCB455C") )
 2412463452
->print DEC ($00$ + ATH ("8FCB455C") )
 2412463452

Title: Re: Hexadecimal to Decimal
Post by: Breidy on September 10, 2021, 03:23:23 PM
Excellent, thank you very much Mike