Hi All

I'm confused on how to convert Hex to numbers in PB, I saw two different forum posts and they give different instructions

in one post https://forum.powerbasic.com/forum/u...241#post528241

it says to use the following formula

while an older post https://forum.powerbasic.com/forum/u...2797#post62797

said that it need to add a leading zero as shown below

So which one should I follow ?

I'm confused on how to convert Hex to numbers in PB, I saw two different forum posts and they give different instructions

in one post https://forum.powerbasic.com/forum/u...241#post528241

it says to use the following formula

Code:

a$ = "ff3a21" a&=val("&h"+a$) 'get the numercal value in a&

while an older post https://forum.powerbasic.com/forum/u...2797#post62797

said that it need to add a leading zero as shown below

Code:

A$ = "FFFF" PRINT VAL$("&H" + A$) PRINT VAL$("&H0" + A$) Results: -1 65535 Also note that VAL() is capable of working with binary and octal strings too: A$ = "1010101" PRINT VAL("&B0" + A$) A$ = "76543" PRINT VAL("&O" + A$)

So which one should I follow ?

## Comment