Author Topic: Long Hex number to decimal  (Read 2091 times)

0 Members and 1 Guest are viewing this topic.

Offline JohnUKresults

  • Newbie
  • Posts: 40
    • View Profile
Long Hex number to decimal
« 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

Offline SMcNeill

  • QB64 Developer
  • Forum Resident
  • Posts: 3972
    • View Profile
    • Steve’s QB64 Archive Forum
Re: Long Hex number to decimal
« Reply #1 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
« Last Edit: April 06, 2020, 09:45:01 am by SMcNeill »
https://github.com/SteveMcNeill/Steve64 — A github collection of all things Steve!

Offline JohnUKresults

  • Newbie
  • Posts: 40
    • View Profile
Re: Long Hex number to decimal
« Reply #2 on: April 06, 2020, 09:50:43 am »
ok thanks - knew there would be a simple way to do it!

Offline JohnUKresults

  • Newbie
  • Posts: 40
    • View Profile
Re: Long Hex number to decimal
« Reply #3 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. :-)