Author Topic: Looking for a quick way to do this tedious hexadecimal math  (Read 220 times)

Fawful Claus

  • Star Spirit
  • *******
  • Fawfulthegreat64
    • View Profile
    • Mario RPG Universe
OK so, I have a list of 44 hexadecimal numbers. I need to increase them all by the same amount. I found this hex calculator which was useful, but it only does one equation at a time. That's a lot of copying and pasting. I can't seem to find something where I can paste all of them and have them each increased by the same amount (also in hexadecimal, which is probably why I'm having trouble finding this, as most calculators are decimal)

Anyone have any suggestions?


santanoice

  • Vee vee
  • Power Star
  • ******
  • fantanoice
  • Happy Holidays!
    • View Profile
    • Twitch
Re: Looking for a quick way to do this tedious hexadecimal math
« Reply #1 on: June 24, 2018, 02:10:58 AM »
You can type "0x?? + 0x?? + 0x??" into Google search bar and do the calculation that way (the "0x" prefix tells the computer it is a hexadecimal number).

Eg: I typed "0x1 + 0x80 + 0x66" and got "0xE7" as the result.

Edit: OK noticing now that you're trying to do multiple equations. It should be pretty easy to program something to loop through your numbers, do the equation and print the result. Lemme see if I can whip something up
« Last Edit: June 24, 2018, 02:16:05 AM by fantanoice »
RIP B. "Walkazo" Dalziel. December 16, 1991 to March 27, 2016.

<< Watch Pokemon Let's Go! Eevee Nuzlocke Stream >>
Ask Me Stuff

Fawful Claus

  • Star Spirit
  • *******
  • Fawfulthegreat64
    • View Profile
    • Mario RPG Universe
Re: Looking for a quick way to do this tedious hexadecimal math
« Reply #2 on: June 24, 2018, 02:16:08 AM »
I was more looking for a way to paste a list of hexadecimal numbers like so:

0x14e38
0x14ed8
0x14f74
and so on

and add the same number (in this case 0xc80) to all of them, giving a new list of each number's sum with 0xc80.

I ended up converting the list to decimal and using a Google Docs spreadsheet to add 3200 to all of them, then converted the results back to hexidecimal but that was still an awkward workaround so I'm still interested if what I mentioned exists. I didn't know Google could recognize that though, so that is good to know.

Edit: I saw your edit. That would be a great resource for this kind of thing, thanks :)
« Last Edit: June 24, 2018, 02:17:50 AM by Fawful with a Monster in Peach's Castle »


santanoice

  • Vee vee
  • Power Star
  • ******
  • fantanoice
  • Happy Holidays!
    • View Profile
    • Twitch
Re: Looking for a quick way to do this tedious hexadecimal math
« Reply #3 on: June 28, 2018, 06:51:32 AM »
Sorry it's been a few days, was busy with things.

Give this code a try. You can run it on this website (it's written in Python):
http://www.skulpt.org

Code: [Select]
toAdd = [ReplaceWithWhatYouWantToAdd]
toAddStr = str(hex(toAdd))
for var in [ReplaceWithYourHexValues]:
    new = hex(var + toAdd)
    print(str(hex(var)) + " + " + toAddStr + " = " + str(new))

Example adding 1 to everything:
Code: [Select]
toAdd = 0x01
toAddStr = str(hex(toAdd))
for var in [0x1,0x55, 0xA]:
    new = hex(var + toAdd)
    print(str(hex(var)) + " + " + toAddStr + " = " + str(new))

Output:
0x1 + 0x1 = 0x2
0x55 + 0x1 = 0x56
0xa + 0x1 = 0xb
RIP B. "Walkazo" Dalziel. December 16, 1991 to March 27, 2016.

<< Watch Pokemon Let's Go! Eevee Nuzlocke Stream >>
Ask Me Stuff

Fawful Claus

  • Star Spirit
  • *******
  • Fawfulthegreat64
    • View Profile
    • Mario RPG Universe
Re: Looking for a quick way to do this tedious hexadecimal math
« Reply #4 on: June 28, 2018, 07:30:05 AM »
Thanks, that's very convenient compared to what I was doing :)