QB64.org Forum

Active Forums => QB64 Discussion => Topic started by: JohnUKresults on April 06, 2020, 09:31:34 am

Title: Long Hex number to decimal
Post by: JohnUKresults on April 06, 2020, 09:31:34 am
Just starting a small project simply to keep my brain ticking over during lockdown.

To save me reinventing the wheel, does anyone have some code for converting a long hex number (mainly 7 hex digits but optional at 12 digits as well) from hex to decimal?

Also the reverse may prove useful at some point.

I can provide some sample codes to save you making them up if that would help.

Thanks
Title: Re: Long Hex number to decimal
Post by: SMcNeill on April 06, 2020, 09:43:56 am
Code: QB64: [Select]
  1. INPUT "Enter your hex$:", h$
  2. PRINT "The value is:"; VAL("&H" + h$)
  3.  
  4. PRINT "The hex$ value of 123456 is: "; HEX$(123456)
  5.  

https://www.qb64.org/wiki/HEX$
https://www.qb64.org/wiki/%26H
Title: Re: Long Hex number to decimal
Post by: JohnUKresults on April 06, 2020, 09:50:43 am
ok thanks - knew there would be a simple way to do it!
Title: Re: Long Hex number to decimal
Post by: JohnUKresults on April 06, 2020, 01:22:59 pm
Hi

Thanks - works fine as long I use the && long integers to get all the decimal digits I need. :-)