Page 1 of 1
How to create function Hex to Dec ?
Posted: Fri Mar 13, 2015 3:24 pm
by Rachata.rath
How to convert hex to dec ?
Example 0xA1 convert to decimal ?
I read from user manual no have this function
Thank you
Re: How to create function Hex to Dec ?
Posted: Fri Mar 13, 2015 3:35 pm
by Mr. Kibernetik
No, currently there is no built-in function to convert HEX to DEC.
Re: How to create function Hex to Dec ?
Posted: Fri Mar 13, 2015 4:03 pm
by Rachata.rath
Do you have example code ?
Re: How to create function Hex to Dec ?
Posted: Fri Mar 13, 2015 4:05 pm
by Mr. Kibernetik
Rachata.rath wrote:Do you have example code ?
Which example code?
Re: How to create function Hex to Dec ?
Posted: Fri Mar 13, 2015 4:14 pm
by Rachata.rath
Hex to dec?
Hex is 0xA1 I want to convert to dec
Dec = HexTODec$(0xA1)
Print Dec
Def HexTODec$()
...
....
End def
Re: How to create function Hex to Dec ?
Posted: Fri Mar 13, 2015 4:16 pm
by Mr. Kibernetik
You can make such function yourself. There is no such function in smart BASIC.
Re: How to create function Hex to Dec ?
Posted: Fri Mar 13, 2015 7:20 pm
by Dutchman
The following program contains a HexToDec-function.
There is no errordetection incorporated!!
Code: Select all
'Hex-Dec calculator
'by Dutchman, march 2015
Hex$="A1"
PRINT "Hexadecimal number '";Hex$;"' = Decimal ";HexToDec(Hex$)
END
DEF HexToDec(IN$)
Base=OPTION_BASE()' save option base
OPTION BASE 0
HEX$="0123456789ABCDEF"
Dec=0
size=LEN(In$)
FOR pos=0 TO Size-1'pos=backward position
n=size-pos-1'n=forward position
c$=MID$(In$,n,1)
val=INSTR(Hex$,CAPSTR$(c$))
Dec+=16^(pos)*val
NEXT pos
OPTION BASE Base
HexToDec=Dec
END DEF
Re: How to create function Hex to Dec ?
Posted: Thu Apr 23, 2015 7:48 pm
by Mr. Kibernetik
Version 4.9 will introduce HEX <=> DEC conversion functions.