Oxygen Basic

Information => Development => Topic started by: Brian Alvarez on January 11, 2019, 07:30:07 PM

Title: Quick question regarding HEX and hexadecimal numbers
Post by: Brian Alvarez 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
Title: Re: Quick question regarding HEX and hexadecimal numbers
Post by: JRS 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

Title: Re: Quick question regarding HEX and hexadecimal numbers
Post by: Charles Pegge 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
Title: Re: Quick question regarding HEX and hexadecimal numbers
Post by: JRS on January 13, 2019, 12:09:56 AM
Slick trick Charles!

Reminds of our SB adventures with MDS and ARM.
Title: Re: Quick question regarding HEX and hexadecimal numbers
Post by: Brian Alvarez 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.
Title: Re: Quick question regarding HEX and hexadecimal numbers
Post by: Brian Alvarez on January 13, 2019, 12:57:52 PM
This is what im getting, image attached.
Title: Re: Quick question regarding HEX and hexadecimal numbers
Post by: Charles Pegge 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
Title: Re: Quick question regarding HEX and hexadecimal numbers
Post by: Brian Alvarez 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?
Title: Re: Quick question regarding HEX and hexadecimal numbers
Post by: Charles Pegge 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


Title: Re: Quick question regarding HEX and hexadecimal numbers
Post by: Brian Alvarez 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. :)