How to convert hex to dec ?
Example 0xA1 convert to decimal ? 
I read from user manual no have this function
Thank you
			
			
									
									
						How to create function Hex to Dec ?
- Mr. Kibernetik
 - Site Admin
 - Posts: 4794
 - Joined: Mon Nov 19, 2012 10:16 pm
 - My devices: iPhone, iPad, MacBook
 - Location: Russia
 - Flag: 

 
Re: How to create function Hex to Dec ?
No, currently there is no built-in function to convert HEX to DEC.
			
			
									
									
						- 
				Rachata.rath
 - Posts: 8
 - Joined: Fri Mar 13, 2015 3:12 pm
 
Re: How to create function Hex to Dec ?
Do you have example code ?
			
			
									
									
						- Mr. Kibernetik
 - Site Admin
 - Posts: 4794
 - Joined: Mon Nov 19, 2012 10:16 pm
 - My devices: iPhone, iPad, MacBook
 - Location: Russia
 - Flag: 

 
Re: How to create function Hex to Dec ?
Which example code?Rachata.rath wrote:Do you have example code ?
- 
				Rachata.rath
 - Posts: 8
 - Joined: Fri Mar 13, 2015 3:12 pm
 
Re: How to create function Hex to Dec ?
Hex to dec?
Hex is 0xA1 I want to convert to dec
Dec = HexTODec$(0xA1)
Print Dec
Def HexTODec$()
...
....
End def
			
			
									
									
						Hex is 0xA1 I want to convert to dec
Dec = HexTODec$(0xA1)
Print Dec
Def HexTODec$()
...
....
End def
- Mr. Kibernetik
 - Site Admin
 - Posts: 4794
 - Joined: Mon Nov 19, 2012 10:16 pm
 - My devices: iPhone, iPad, MacBook
 - Location: Russia
 - Flag: 

 
Re: How to create function Hex to Dec ?
You can make such function yourself. There is no such function in smart BASIC.
			
			
									
									
						- Dutchman
 - Posts: 872
 - Joined: Mon May 06, 2013 9:21 am
 - My devices: iMac, iPad Air, iPhone
 - Location: Netherlands
 - Flag: 

 
Re: How to create function Hex to Dec ?
The following program contains a HexToDec-function.
There is no errordetection incorporated!!
			
			
									
									
						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- Mr. Kibernetik
 - Site Admin
 - Posts: 4794
 - Joined: Mon Nov 19, 2012 10:16 pm
 - My devices: iPhone, iPad, MacBook
 - Location: Russia
 - Flag: 

 
Re: How to create function Hex to Dec ?
Version 4.9 will introduce HEX <=> DEC conversion functions.