Author Topic: Quick question regarding HEX and hexadecimal numbers  (Read 193 times)

0 Members and 1 Guest are viewing this topic.

Brian Alvarez

  • Full Member
  • ***
  • Posts: 218
    • PluriBASIC
Quick question regarding HEX and hexadecimal numbers
« on: January 11, 2019, 07:30:07 PM »
Does HEX() support QUAD?
Does Oxygen support big hexadecimals like "0x1D4A9EBC4E94E60"?

Note: Im trying to support %PB_COMPILETIME

John

  • Hero Member
  • *****
  • Posts: 3529
Re: Quick question regarding HEX and hexadecimal numbers
« Reply #1 on: January 11, 2019, 07:57:44 PM »
This is what Script BASIC returns. The HEX is broken for 64 bits.  :( What is O2 returning for you?

Code: Script BASIC
  1. numhex =  0x1D4A9EBC4E94E60
  2. PRINT numhex,"\n"
  3. PRINT HEX(numhex),"\n"
  4.  


$ scriba phex.sb
131917119186620000
       C4E94E60
$


Good News!

AIR fixed it.

$ ./scriba phex.sb
131917119186620000
1D4A9EBC4E94E60

« Last Edit: January 11, 2019, 09:11:25 PM by John »

Charles Pegge

  • Admin Support Member
  • *****
  • Posts: 3946
    • Oxygen Basic
Re: Quick question regarding HEX and hexadecimal numbers
« Reply #2 on: January 12, 2019, 10:37:03 PM »
Hi Brian,

Currently, o2 does not support number literals above 32bits, so you will have to load the quad with an expression:

quad a=0x12345678*0x10000*0x10000+0x9abcdef01

quad b=0x1D4A9EB*0x10000*0x10000+0xC4E94E60

John

  • Hero Member
  • *****
  • Posts: 3529
Re: Quick question regarding HEX and hexadecimal numbers
« Reply #3 on: January 13, 2019, 12:09:56 AM »
Slick trick Charles!

Reminds of our SB adventures with MDS and ARM.

Brian Alvarez

  • Full Member
  • ***
  • Posts: 218
    • PluriBASIC
Re: Quick question regarding HEX and hexadecimal numbers
« Reply #4 on: January 13, 2019, 12:40:09 PM »
Thanks charles! that worked!

Sort of... It works fine for 32 bit compilations, but 64 bit compilations are off...
Maybe its just the hex and str functions.

Brian Alvarez

  • Full Member
  • ***
  • Posts: 218
    • PluriBASIC
Re: Quick question regarding HEX and hexadecimal numbers
« Reply #5 on: January 13, 2019, 12:57:52 PM »
This is what im getting, image attached.
« Last Edit: January 13, 2019, 01:30:05 PM by Brian Alvarez »

Charles Pegge

  • Admin Support Member
  • *****
  • Posts: 3946
    • Oxygen Basic
Re: Quick question regarding HEX and hexadecimal numbers
« Reply #6 on: January 13, 2019, 09:00:16 PM »
Yes, I see the problem.

This works on both 32bit and 64bit. (qs must come first):

quad qs=0x10000 : qs*=0x10000
quad a= qs*0x12345678+0x9abcdef0

Brian Alvarez

  • Full Member
  • ***
  • Posts: 218
    • PluriBASIC
Re: Quick question regarding HEX and hexadecimal numbers
« Reply #7 on: January 13, 2019, 09:42:08 PM »
That worked pretty well. :)

 Now... do you think the fact that the order of operation disrupts the result will affect with other calculations? That kind of concerns me.

 Also, should i work on expanding my STR$ function, or the existing one supports 18 digits somehow?

Charles Pegge

  • Admin Support Member
  • *****
  • Posts: 3946
    • Oxygen Basic
Re: Quick question regarding HEX and hexadecimal numbers
« Reply #8 on: January 14, 2019, 08:30:30 AM »
Hi Brian,

There was an asm fault affecting 64bit quad multiply and divide. I will post the fix, so the order no longer matters.

re: internal number formatting:

numberformat allows you to control the global number format settings:

Code: [Select]
    'int dp   ' DECIMAL PLACES
    'int trz  ' STRIP TRAILING ZEROS
    'int sn   ' SCIENTIFIC NOTATION BY DEFAULT
    'int sdp  ' INHIBIT ZERO BEFORE DECIMAL POINT
    'int sns  ' LEADING SPACE FOR NON NEGATIVE NUMBERS
    'int lps  ' LEAD PADDING SPACES

numberformat(16,1,0,0,0,0) 'default settings
numberformat 'return to default



Brian Alvarez

  • Full Member
  • ***
  • Posts: 218
    • PluriBASIC
Re: Quick question regarding HEX and hexadecimal numbers
« Reply #9 on: January 14, 2019, 10:40:07 AM »
Outstanding! Thank you Charles!! :D

 Unfortunately i couldnt figure out a combination that suits all 18 digits (should be 19, but 1 is reserved i think) of quads.  ;D
But i will get back to it. :)
« Last Edit: January 14, 2019, 12:23:09 PM by Brian Alvarez »