Author Topic: Documentation  (Read 65911 times)

0 Members and 1 Guest are viewing this topic.

Mike Lobanovsky

  • Guest
Re: Documentation
« Reply #90 on: October 04, 2018, 09:13:56 AM »
... MAXINT and MININT ranges.
........
9223372036854775807
-9223372036854775808

Those are 64-bit values. The functions only reflect the capabilities of the operating system SB is currently running on but not the capabilities of SB proper. AFAIK SB is only capable of 32-bit integer calc on both 32- and 64-bit platforms, alas.
« Last Edit: October 04, 2018, 09:25:02 AM by Mike Lobanovsky »

JRS

  • Guest
Re: Documentation
« Reply #91 on: October 04, 2018, 09:35:41 AM »
... MAXINT and MININT ranges.
........
9223372036854775807
-9223372036854775808

Those are 64-bit values. The functions only reflect the capabilities of the operating system SB is currently running on but not the capabilities of SB proper. AFAIK SB is only capable of 32-bit integer calc on both 32- and 64-bit platforms, alas.

Code: Script BASIC
  1. PRINT FORMAT("%i",9000000000000000000 - 10), "\n"
  2.  


jrs@jrs-laptop:~/sb/examples/test$ scriba intmath.sb
8999999999999999990
jrs@jrs-laptop:~/sb/examples/test$


If that's the case my example shouldn't be working. SB has some issues with 64 bit PRINT / FORMAT and REAL. A couple other functions might need work for 64 bit.


« Last Edit: October 04, 2018, 12:44:13 PM by John »

Arnold

  • Guest
Re: Documentation
« Reply #92 on: October 04, 2018, 10:25:14 AM »
Thank you, Charles. Using the float/int approach I can find the expected 23/8/1 values:

 3.4028234663852886E+38   hex: 7F7FFFFF
-3.4028234663852886E+38   hex: FFFFFFFF FF7FFFFF

Using the double/quad approach I can also find the expected 52/11/1 values:

 1.7976931348623157E+308   hex: 7FEFFFFFFFFFFFFF
-1.7976931348623157E+308   hex: FFEFFFFFFFFFFFFF

I suppose to get the values for the extended type is not so easy?

Roland

Charles Pegge

  • Guest
Re: Documentation
« Reply #93 on: October 04, 2018, 12:19:34 PM »
You'll need three ints to span the extended float:

these have:
64 bits significand
15 bits exponent
1 sign bit

Code: [Select]
extended f=123.45
int i at @f
string fmt(int v){ return right(hex(v,8),8) }
print fmt(i[3]and 0xffff) "  " fmt(i[2]) "  " fmt(i[1])

https://en.wikipedia.org/wiki/Extended_precision
« Last Edit: October 04, 2018, 02:30:57 PM by Charles Pegge »

Mike Lobanovsky

  • Guest
Re: Documentation
« Reply #94 on: October 04, 2018, 12:43:59 PM »
Code: [Select]
PRINT FORMAT("%i",9000000000000000000 - 10), "\n"


jrs@jrs-laptop:~/sb/examples/test$ scriba intmath.sb
8999999999999999990
jrs@jrs-laptop:~/sb/examples/test$


Oh.

That should be 64-bit Linux, I presume. My bad.

JRS

  • Guest
Re: Documentation
« Reply #95 on: October 04, 2018, 06:11:14 PM »
You were correct about Windows. (32/64 bit)  I gave it a try on Script BASIC 64 bit Windows and it only shows MAXINT and MININT to be 32 bit values.

Code: Script BASIC
  1. PRINT MAXINT,"\n"
  2. PRINT MININT,"\n"
  3.  



For me, SB on Windows is a 32 bit solution. I don't have the time or desire to extend types and masks for 64 bit to work. SB Linux only has a couple minor issues under 64 bit.
« Last Edit: October 04, 2018, 07:47:23 PM by John »

Arnold

  • Guest
Re: Documentation - extended data type
« Reply #96 on: October 05, 2018, 02:13:14 PM »
Hi Charles,

your formulas are suitable for developing a small floating point converter.

Looking for the maximum and minimum values of the extended type I finally found: 1.18973149535723176502e4932 which can be calculated with 2^16384. But I also found the LDBL_MIN constant which indicates the minimum positive value: 3.36210314311209350626e-4932. This can be calculated with 2^-16382 or 1/(2^16382). This seems not to work in Oxygenbasic. Is there still another way to calculate with a negative exponent?

Roland

Code: [Select]
$ filename "Ext_limits.exe"

'uses rtl32
'uses rtl64

uses console

string fmt(int v){ return right(hex(v,8),8) }

'extended f=1.18973149535723176502e4932   'LDBL_MAX
extended f=2^16384

int i at @f
printl f ",  hex: " fmt(i[3]and 0xffff) "  " fmt(i[2]) "  " fmt(i[1])

'f=-1.18973149535723176502e4932
f=-(2^16384)
printl f ", hex: " fmt(i[3]and 0xffff) "  " fmt(i[2]) "  " fmt(i[1]) & cr

'f=3.36210314311209350626e-4932           'LDBL_MIN  - min positive value
f=2^-16382
'f=1/(2^16382)
'f=pow(2,-16382)
printl f
printl fmt(i[3]and 0xffff) "  " fmt(i[2]) "  " fmt(i[1]) & cr

printl "Enter ... " : waitkey

JRS

  • Guest
Re: Documentation
« Reply #97 on: October 05, 2018, 04:33:39 PM »
José,

Do you think it will be easier to port your includes to O2 then what it took to go to FreeBasic?

José Roca

  • Guest
Re: Documentation
« Reply #98 on: October 05, 2018, 04:45:06 PM »
Absolutely not. With the current state of affairs, most of the classes can't be ported keeping all of its functionality and ease of use.

JRS

  • Guest
Re: Documentation
« Reply #99 on: October 05, 2018, 04:47:45 PM »
That isn't what I was hoping to hear.

I can't say thank you enough for the outstanding job you are doing with the O2 docs.

Charles Pegge

  • Guest
Re: Documentation
« Reply #100 on: October 06, 2018, 12:25:27 AM »
Hi Roland,

You can use pow(a,b) as an alternative to a^b, though they should give the same result.

JRS

  • Guest
Re: Documentation - OT
« Reply #101 on: October 06, 2018, 02:14:20 AM »
José,

I plan to adapt your documentation format for my migration of Script BASIC as forum based to a GitLab repository. I already have GitLab CS installed on the hosting server but I need to deal with Plesk issues to get it working. I'm thinking it could be used as a sandbox of sorts.


Arnold

  • Guest
Re: Documentation extended data types
« Reply #102 on: October 06, 2018, 02:48:50 AM »
Hi Charles,

this seems to be an overflow issue. Oxygen accepts a negative exponent up to 2^-16330. I will try to use logarithms (it has been so long since I used them)

Roland

Code: [Select]
uses console

extended e
e=-1.18973149535723176502e4932           'LDBL_MAX
printl e
e=2^16384
printl e
e=3.36210314311209350626e-4932           'LDBL_MIN  - min positive value
printl e
e=2^-16382    'Windows calculator
printl e
e=2^-16330
printl e

waitkey

Arnold

  • Guest
Re: Documentation
« Reply #103 on: October 08, 2018, 01:21:22 AM »
Hi José,

you are incredibly fast and very systematic. The documentation will be a valuable addition to the Oxygen help file.

Will it eventually be possible to use the documentation for offline reading? At the moment, hyperlinks do not work if I copy the files as HTML pages (not a real problem).

Roland

  • Guest
Re: Documentation
« Reply #104 on: October 08, 2018, 05:47:44 AM »
Another way is to convert it to .pdf.

Given the address of a page

https://github.com/JoseRoca/WinPBX/blob/master/docs/Oxygen/Data%20Types.md

change the github part of the address to gitprint in your browser:

https://gitprint.com/JoseRoca/WinPBX/blob/master/docs/Oxygen/Data%20Types.md

Although it does not support hyperlinks.
« Last Edit: October 08, 2018, 05:56:04 AM by José Roca »