True 64-bit Applications in PureBasic and Huge Numeric Types

Everything else that doesn't fall into one of the other PB categories.
User avatar
Ion Saliu
User
User
Posts: 14
Joined: Tue Oct 25, 2011 5:24 pm
Location: Gettysburg, PA, USA
Contact:

True 64-bit Applications in PureBasic and Huge Numeric Types

Post by Ion Saliu »

Hello, programming colleagues of mine!

Like many of you, I started with basic … BASIC — from GWBasic, to QuickBasic, to Microsoft PDS Basic, to Visual Basic. Meanwhile, I adopted also the PowerBasic console compiler (PBCC) of a much smaller company (probably a one-man show).

I preferred the speed of console applications (non-GUI or formless). It was also my beginning in DOS! The transition from 16-bit to 32-bit PBCC was adequately easy. I’ve written over 100 programs, mainly in mathematics, probability, lottery, and gambling:

http://software.saliu.com/

Transitioning to a new platform is NOT easy, even if it is from one Basic to another Basic. Here is why I want to move one to another platform: 64-bit computing. Computing moves very, very fast. Soon, all software will be 64-bit. PowerBasic does NOT seem capable of writing 64-bit software. I asked them (other programmers asked too) to offer 64-bit compilers. Years have passed and nothing has happened. I also asked them to offer a HUGE numerical type to take advantage of the 64-bit architecture. No answer, either. They still offer an 18-digt wide data type (QUAD). I heard a small BASIC interpreter offers a 2600-digit wide numerical type! It’s UBasic — but there is no validation for that data type from an organization like IEEE.

And thus I googled and googled and I found PureBasic. I sent first an email to support. They assured me that PureBasic can create TRUE 64-bit applications! I mean, it’s not the hybrid that Microsoft offers: a maximum object size of 2 GB like in 32-bit operating systems. I want all that 2 ^ 64 = 18,446,744,073,709,551,616 address space, etc.

I also want HUGE data types. I read through the FAQ and other sources. I haven’t been able to find the maximum size for numerical type; that is, the maximum number of digits in length. I need to make myself clearer. I mean DIGITS as in the 10-base numeric system, not binary. 2 ^ 10 = 1024 but 10 ^ 10 = 10,000,000,000. I can trust the CURRENCY data type in VB6: 300 digits. If it were not precise, Microsoft would have been destroyed by now in lawsuits!

1) So, PureBasic applications can be TRULY 64-bit software, not the 32-bit/64-bit hybrid.
2) What is the maximum data size for numeric values, digits?
3) Can I create formless applications, like in PBCC?

Thank you for your consideration.

Ion Saliu
User avatar
Shield
Addict
Addict
Posts: 1021
Joined: Fri Jan 21, 2011 8:25 am
Location: 'stralia!
Contact:

Re: True 64-bit Applications in PureBasic and Huge Numeric T

Post by Shield »

Hi and welcome to the forums! :)

1) Yes, you can create 32bit and 64bit applications.
2) The largest built-in type in PureBasic is the quad (which is 8 bytes) giving you a theoretical total of 2^64. However, do note that all types in PB are signed!
But that doesn't mean that it isn't possible to do calculations with larger numbers. There are many arbitrary number libraries out there which you can use within PB
if you create required include files. :)
3) You can create console applications and, of course, regular windows applications that do or do not show any windows.
Image
Blog: Why Does It Suck? (http://whydoesitsuck.com/)
"You can disagree with me as much as you want, but during this talk, by definition, anybody who disagrees is stupid and ugly."
- Linus Torvalds
User avatar
Ion Saliu
User
User
Posts: 14
Joined: Tue Oct 25, 2011 5:24 pm
Location: Gettysburg, PA, USA
Contact:

Re: True 64-bit Applications in PureBasic and Huge Numeric T

Post by Ion Saliu »

Shield:

Thank you so much for your prompt reply.

Now, it is reassuring that PureBasic creates true 64-bit applications in formless (console) state. I am not a fan of GUI-applications because the windows mean an overhead for my software. My programs are numerical-intense and need as much speed as they can get.

As of the third-party math libraries — I don’t trust them much. Keyword here is VALIDATION. If they are not validated by a reputable organization like IEEE, I don’t trust the libraries. I had some unpleasant experiences. Ultimately, the numeric size is limited by the data types of the compiler. I tried myself also some logarithmic tricks — there is no precision after 18 digits (the limit in PBCC)! Perhaps PureBasic will take Microsoft’s example and offer a 300-digit wide numerical data. Do you know of trustworthy third-party mathematical libraries? I would appreciate a few names …

In any event, I will buy PureBasic today. I see they don’t support PayPal … but I’ll try a card.
Ramihyn_
Enthusiast
Enthusiast
Posts: 314
Joined: Fri Feb 24, 2006 9:40 am

Re: True 64-bit Applications in PureBasic and Huge Numeric T

Post by Ramihyn_ »

Welcome to the forum.

Integers (.i) and Quads (.q) in 64-bit PureBasic programs have a range of -9223372036854775808 to +9223372036854775807

You can write console programs, but writing GUI programs for windows is actually so simple, that PureBasic for windows is a good choice to switch to GUI applications later.
Ion Saliu wrote:As of the third-party math libraries — I don’t trust them much. Keyword here is VALIDATION. If they are not validated by a reputable organization like IEEE, I don’t trust the libraries. I had some unpleasant experiences. Ultimately, the numeric size is limited by the data types of the compiler. I tried myself also some logarithmic tricks — there is no precision after 18 digits (the limit in PBCC)! Perhaps PureBasic will take Microsoft’s example and offer a 300-digit wide numerical data. Do you know of trustworthy third-party mathematical libraries? I would appreciate a few names …
You can find plenty of libraries listed here:
http://en.wikipedia.org/wiki/Arbitrary- ... arithmetic

Most Libraries for windows will be delivered as a DLL and with PureBasic you can use those easily.
Last edited by Ramihyn_ on Tue Oct 25, 2011 6:37 pm, edited 2 times in total.
Trond
Always Here
Always Here
Posts: 7446
Joined: Mon Sep 22, 2003 6:45 pm
Location: Norway

Re: True 64-bit Applications in PureBasic and Huge Numeric T

Post by Trond »

a maximum object size of 2 GB like in 32-bit operating systems. I want all that 2 ^ 64 = 18,446,744,073,709,551,616 address space, etc.
Even though the address space is big, remember that most computers don't have more than 4 GB of memory, so that will put a maximum limit for memory use.

9223372036854775807 is the biggest number you can have in PureBasic using the type "quad". This is in the help file on the page "variables, types and operators".

In .NET 4 there is a type called System.Numerics.BigInteger which is basically unlimited. Maybe that is a better option.
User avatar
Shield
Addict
Addict
Posts: 1021
Joined: Fri Jan 21, 2011 8:25 am
Location: 'stralia!
Contact:

Re: True 64-bit Applications in PureBasic and Huge Numeric T

Post by Shield »

Ion Saliu wrote: Ultimately, the numeric size is limited by the data types of the compiler.
Only for the built-in types. ;)
But that's why those libraries exist. Of course using such a library is slower than using plain integers because
the processor is not optimized for such large numbers.
Ion Saliu wrote: Do you know of trustworthy third-party mathematical libraries? I would appreciate a few names …
GMP is probably the most widely used arbitrary precision library:
http://en.wikipedia.org/wiki/GNU_Multi- ... on_Library
Image
Blog: Why Does It Suck? (http://whydoesitsuck.com/)
"You can disagree with me as much as you want, but during this talk, by definition, anybody who disagrees is stupid and ugly."
- Linus Torvalds
User avatar
netmaestro
PureBasic Bullfrog
PureBasic Bullfrog
Posts: 8451
Joined: Wed Jul 06, 2005 5:42 am
Location: Fort Nelson, BC, Canada

Re: True 64-bit Applications in PureBasic and Huge Numeric T

Post by netmaestro »

(probably a one-man show)
Agreed, that's my take as well.
BERESHEIT
User avatar
Ion Saliu
User
User
Posts: 14
Joined: Tue Oct 25, 2011 5:24 pm
Location: Gettysburg, PA, USA
Contact:

Re: True 64-bit Applications in PureBasic and Huge Numeric T

Post by Ion Saliu »

Only for the built-in types.
But that's why those libraries exist. Of course using such a library is slower than using plain integers because the processor is not optimized for such large numbers.
My most serious problem is VALIDATION. Who is the third-party who validates the precision of a math library? I don’t care what the vendor says, especially if it represents a small entity. So, again, when it comes to math library, the most important factor is: VALIDATION, VALIDATION, VALIDATION!

I DO TRUST Microsoft, however, regarding their 300-digit-accuracy CURRENCY type in VB6. They are a huge entity and could have been destroyed in lawsuits — IF the accuracy of CURRENCY was not met.

Anyway, I’ll take another look at the links to math libraries members posted here — thanks! Has anyone tried one or two of them? Any verification?
In .NET 4 there is a type called System.Numerics.BigInteger which is basically unlimited. Maybe that is a better option.
WOW! Unlimited!! Why doesn’t Microsoft sell the source code to that numerical data type? They could make more money than from Bing(o)!

I stopped at Visual Basic 6. the .NET paradigm turned me off. First, it was unsecure — every programmer could peek at your source code! Besides, the concept is very cumbersome and time consuming. Most programmers cried foul: NET was a very bad idea. I would have loved a CLASSIC Visual Basic 7, then 8, 9, 10 …

OK guys. I will order PureBasic right now. Thanks again for your answers. I am aware of the difficulties of recompiling some of my programs in PureBasic. I will have to REWRITE a lot of code. Many things in PureBasic look very different from PowerBasic. I hope I’ll find helping hands here.
User avatar
netmaestro
PureBasic Bullfrog
PureBasic Bullfrog
Posts: 8451
Joined: Wed Jul 06, 2005 5:42 am
Location: Fort Nelson, BC, Canada

Re: True 64-bit Applications in PureBasic and Huge Numeric T

Post by netmaestro »

However, do note that all types in PB are signed!
Type .a is unsigned byte, .u is unsigned word.
BERESHEIT
User avatar
Shield
Addict
Addict
Posts: 1021
Joined: Fri Jan 21, 2011 8:25 am
Location: 'stralia!
Contact:

Re: True 64-bit Applications in PureBasic and Huge Numeric T

Post by Shield »

Ion Saliu wrote: WOW! Unlimited!! Why doesn’t Microsoft sell the source code to that numerical data type?
Because there are a ton of such libraries / classes out there, for free?
It's not that hard to write an arbitrary precision class just for integers.
Image
Blog: Why Does It Suck? (http://whydoesitsuck.com/)
"You can disagree with me as much as you want, but during this talk, by definition, anybody who disagrees is stupid and ugly."
- Linus Torvalds
User avatar
Ion Saliu
User
User
Posts: 14
Joined: Tue Oct 25, 2011 5:24 pm
Location: Gettysburg, PA, USA
Contact:

Re: True 64-bit Applications in PureBasic and Huge Numeric T

Post by Ion Saliu »

Shield:
It's not that hard to write an arbitrary precision class just for integers.
See, that term, arbitrary scares me. I want total precision, not arbitrary. One good assembly programmer told me the same thing, that’s not too hard to write your own mathematical libraries, etc.

Ultimate Lexicographical Indexing

Because there are a ton of such libraries / classes out there, for free?
Can you recommend me a couple that you trust the most?
I downloaded and installed PureBasic for 64-bit Windows. I’ll write about it next …

Thanks!
User avatar
Shield
Addict
Addict
Posts: 1021
Joined: Fri Jan 21, 2011 8:25 am
Location: 'stralia!
Contact:

Re: True 64-bit Applications in PureBasic and Huge Numeric T

Post by Shield »

You can't get total precision because we live in a finite universe. :wink:
Precision is limited by the available RAM.

I already posted that I'd go with GMP, which, if I'm not mistaken, can also handle rational numbers so you can
at least do precise calculations with terms like 1/3. :wink:
Image
Blog: Why Does It Suck? (http://whydoesitsuck.com/)
"You can disagree with me as much as you want, but during this talk, by definition, anybody who disagrees is stupid and ugly."
- Linus Torvalds
User avatar
Ion Saliu
User
User
Posts: 14
Joined: Tue Oct 25, 2011 5:24 pm
Location: Gettysburg, PA, USA
Contact:

Re: True 64-bit Applications in PureBasic and Huge Numeric T

Post by Ion Saliu »

I downloaded and installed PureBasic for 64-bit Windows about an hour ago. I am really impressed! The editor has a CLASSY look — reminds me of Visual Basic 6. PureBasic editor has a more modern appearance, however. Probably the European stylish thingy!

Since this is a European creation, I was a little afraid about the quality of the help and documentation. Not to worry — it’s all clear. By the way, I was born in Romania.

I was also a little afraid because I didn’t see a RND function or statement. My software has a lot of random generation. Then, I discovered a very good function named, more meaningfully,
Random
. Plus a cryptography form of Random. That was interesting! I have a very good random seed, however, probably the best, TheSeeder:

BASIC Language Source Code Software to Generate True Random and Unique Numbers

It’s very easy to adapt it to all your needs. It is based on date, including the year.

Now, what I need is TIME to adapt my PBCC source code to PureBasic. Are there any tools available to make the transition easier?

Thank you all and best of luck to you!
jack
Addict
Addict
Posts: 1358
Joined: Fri Apr 25, 2003 11:10 pm

Re: True 64-bit Applications in PureBasic and Huge Numeric T

Post by jack »

you can find a totally free multi-precision integer library at http://libtom.org/
for decimal floating point there's the decNumber library http://speleotrove.com/decimal/decnumber.html
I posted translation of the headers somewhere on this forum, but they may need revising, especially to make sure that they are 64-bit clean.
for multi-precision floating point you probably should go with MPIR instead of GMP because MPIR is 64-bit clean, last time I checked GMP was still working on the 64 bit version, but it's been a while since I checked.
wilbert
PureBasic Expert
PureBasic Expert
Posts: 3942
Joined: Sun Aug 08, 2004 5:21 am
Location: Netherlands

Re: True 64-bit Applications in PureBasic and Huge Numeric T

Post by wilbert »

I'm a bit confused about the currency type that is mentioned. Where are the 300 digits ?
All I can find is that currency is an 8-byte number with fixed decimal point that can hold values from –922,337,203,685,477.5808 to 922,337,203,685,477.5807 .
Locked