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
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 »

Yeah, never heard of a 300 digit type before either.
However, .NET features a native 128 bit fixed point data type to do currency calculations.
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
c4s
Addict
Addict
Posts: 1981
Joined: Thu Nov 01, 2007 5:37 pm
Location: Germany

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

Post by c4s »

Hi there, I've read some controversial stuff about your homepage and what you're doing. It included that you really like to back-link to your homepage (for SEO reasons?!)... Anyway, it isn't forbidden but I hope that you're not going to flood every post with it :wink:
Ion Saliu's signatur wrote:BASIC Software Developer
About your need for big numbers:
Besides the recommended GMP library (discussions: here, here and here: search) you can even find something written in PureBasic:
- http://www.purebasic.fr/english/viewtop ... 12&t=39842
- http://purebasic.fr/german/viewtopic.php?f=8&t=22466 (http://www.jasik.de/downloads/purebasic/bigdecimal.pb)
- http://www.purebasic.fr/german/viewtopi ... 27#p262227 (http://data.unionbytes.de/Decimal.pbi)
If any of you native English speakers have any suggestions for the above text, please let me know (via PM). Thanks!
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 said CURRENCY, when, in fact, I was referring to the VB data type known as DOUBLE (precision). Here is what the MSDN Library writes (serves as the help facility for all Visual Studio components). I posted about it in another programming forum in 2008. I copied and pasted from MSDN Library (as of June 2000):
“DOUBLE = 8 bytes ~ A double-precision floating-point value with a range of – 1.79769313486232E308 to – 4.94065645841247E-324 for negative values, 4.94065645841247E-324 to 1.79769313486232E308 for positive values, and 0.

The highest positive value of a Double data type is 1.79769313486232D+308, or about 1.8 times 10 to the 308th power.”
Maybe it fooled me! MSDN Library (June 2000 was the last edition I have) says clearly: 1.8 times 10 to the 308th power. Now, I believe my math is correct: 10 to the 10th power equals 10,000,000,000 (1 followed by 10 zeros). Shouldn’t 10 to the 308th power equal 1 followed by 308 zeros?

Sorry, if you thought my intent was to backlink! I was only interested in a 64-bit Basic compiler — I’m glad I found it here. Matter of fact, I will post soon in my forum a linkback to this forum and site. There are programmers in my forum. We have written quite a bit about compilers and data types, etc. I’m sure some of the programmers will find your compiler very useful.

As of those third-party mathematical libraries, I thank you all again. There is, however, one point I stressed and there has been no answer: VALIDATION. I haven’t found a single math library, free or paid, that was validated by IEEE. Perhaps Microsoft was wrong — many programmers in that forum disputed my quoted excerpt.

Now, I do need time to figure out PureBasic. Definitely, I must do a lot of rewriting of my source code, besides the trusted search-and-replace.

Best of luck to you all!
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 »

PureBasic has the double type also.
You are right that it can hold very large values but the precision is limited to 53 bits (about 16 digits).
I assumed you were looking for something with more accuracy.
User avatar
Blood
Enthusiast
Enthusiast
Posts: 161
Joined: Tue Dec 08, 2009 8:34 pm
Location: United Kingdom

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

Post by Blood »

What the holy f**k: http://saliu.com/Ion_Saliu.html ???
C provides the infinitely-abusable goto statement, and labels to branch to. Formally, the goto is never necessary, and in practice it is almost always easy to write code without it. We have not used goto in this book. -- K&R (2nd Ed.) : Page 65
User avatar
luis
Addict
Addict
Posts: 3893
Joined: Wed Aug 31, 2005 11:09 pm
Location: Italy

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

Post by luis »

wilbert wrote: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 .
I don't understand that either, I used VB6 for a job years ago, I remember Currency as a big integer of a sort with fixed precision to the fourth decimal. I believe it was an integer internally to VB, then divided by the appropriate number (10000 ?) at the moment of the output.


EDIT: oh, sorry I replied to wilbert's post and I didn't see there was a second page of posts already :?
"Have you tried turning it off and on again ?"
A little PureBasic review
Zach
Addict
Addict
Posts: 1675
Joined: Sun Dec 12, 2010 12:36 am
Location: Somewhere in the midwest
Contact:

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

Post by Zach »

Blood wrote:What the holy f**k: http://saliu.com/Ion_Saliu.html ???
A little eccentric, but he appears to be a mathematician / statistician of some sort. Interesting reading!

I remember reading through a back issue of Run! (C64 Magazine) some code for a lottery program someone wrote. I'd always been fascinated with the idea, but assumed I'd never have the understanding to write something even marginally accurate. I guess that's what hes doing :mrgreen:
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:
PureBasic does also have the value type 'double', however this data type is not accurate at all (and it's not even designed to be accurate).
The bigger the value gets (or the more decimal points it needs to hold), the more inaccurate results appear.
So if you want to do "precise" operations, double clearly is the wrong way to go. Double is optimized for speed, not precision.
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 »

Blood wrote:What the holy f**k: http://saliu.com/Ion_Saliu.html ???
You would say correctly:

“What the Bloody f**k!”

@Shield - As of huge numbers, I seem to be out of luck! I suggest the PureBasic team to take a look at the Japanese UBasic. It was created by an academic — he should be a more reasonable human than regular programmers. I suggest you contact him and maybe ask for permission to incorporate in PureBasic his HUGE NUMERIC data type. The programming samurai claims 2600-digt precision in his numbers!!! Hard to believe! But, hopefully, there will be cooperation with a programming musketeer :)
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 »

take a look at the Japanese UBasic. It was created by an academic — he should be a more reasonable human than regular programmers.

Sounds perfect for you. Thanks for stopping by and good luck with your quest for numerizing luck, unfortunately that's pretty much not what we do here.
BERESHEIT
User avatar
Danilo
Addict
Addict
Posts: 3036
Joined: Sat Apr 26, 2003 8:26 am
Location: Planet Earth

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

Post by Danilo »

- Ion Saliu is the fastest human in history to write a BigNum library.

- Ion Saliu is the fastest human in history to write a compiler for high precision math.

- Ion Saliu is the fastest grandpa-superman in history.

If you are a bit serious, Ion Saliu, you should already know about Intel C++ and Fortran Compilers
and its high performance math libraries.
With Intel C++/Fortran & MKL (Math Kernel Library) & IPP (Integrated Performance Primitives) &
TBB (Threading Building Blocks) you should be able to write everything you want and it is compiled
by one of the best optimizing compilers in the world. It is not expensive.
Introducing the Intel(R) Math Kernel Library
The Intel(R) Math Kernel Library (Intel(R) MKL) enables improving performance of scientific, engineering, and financial software that solves large computational problems. Intel MKL provides a set of linear algebra routines, fast Fourier transforms, as well as vectorized math and random number generation functions, all optimized for the latest Intel(R) processors, including processors with multiple cores (see the Intel(R) MKL Release Notes for the full list of supported processors). Intel MKL also performs well on non-Intel processors.

Intel MKL provides the following major functionality:
  • Linear algebra, implemented in LAPACK (solvers and eigensolvers) plus level 1, 2, and 3 BLAS, offering the vector, vector-matrix, and matrix-matrix operations needed for complex mathematical software. If you prefer the FORTRAN 90/95 programming language, you can call LAPACK driver and computational subroutines through specially designed interfaces with reduced numbers of arguments. C interface to LAPACK routines is also available.
  • ScaLAPACK (SCAlable LAPACK) with its support functionality including the Basic Linear Algebra Communications Subprograms (BLACS) and the Parallel Basic Linear Algebra Subprograms (PBLAS). Available with Intel MKL for Linux* and Windows* operating systems.
  • Direct sparse solver, an iterative sparse solver, and a supporting set of sparse BLAS (level 1, 2, and 3) for solving sparse systems of equations.
  • Multidimensional discrete Fourier transforms (1D, 2D, 3D) with a mixed radix support (not limited to sizes of powers of 2). Distributed versions of these functions are provided for use on clusters on the Linux* and Windows* operating systems.
  • A set of vectorized transcendental functions called the Vector Math Library (VML). For most of the supported processors, the Intel MKL VML functions offer greater performance than the libm (scalar) functions, while keeping the same high accuracy.
  • The Vector Statistical Library (VSL), which offers high performance vectorized random number generators for several probability distributions, convolution and correlation routines, and summary statistics functions.
Intel MKL is thread-safe and extensively threaded using the OpenMP* technology.

For details see the Intel(R) MKL Reference Manual.
Of course it's 32bit and 64bit native compilers and libraries.

I recommend Intel C++ Studio XE 2011 which includes:
  • Intel C++ Compiler
  • Intel Integrated Performance Primitives
  • Intel Threading Building Blocks
  • Intel Math Kernel Library
  • Intel VTune Performance Analyzer
  • Intel Thread Checker
It's about US$ 1,500 / 900 Euro initial product price for the complete suite,
but only US$ 600 / 360 Euro per year for support and upgrades.
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_ »

Ion Saliu wrote:@Shield - As of huge numbers, I seem to be out of luck! I suggest the PureBasic team to take a look at the Japanese UBasic. It was created by an academic — he should be a more reasonable human than regular programmers. I suggest you contact him and maybe ask for permission to incorporate in PureBasic his HUGE NUMERIC data type. The programming samurai claims 2600-digt precision in his numbers!!! Hard to believe! But, hopefully, there will be cooperation with a programming musketeer :)
You can have arbitrary precision math with different libraries if you actually read the link i gave you two days ago. Thats more than 2600-digit precision ;)

And if you are really serious about validation by IEEE, then maybe you should ask them if and which library they ever validated?

ps: http://en.wikipedia.org/wiki/Computational_science
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 »

Danilo:
It's about US$ 1,500 / 900 Euro initial product price for the complete suite, but only US$ 600 / 360 Euro per year for support and upgrades.
Now, that’s affordable :lol: In all fairness, however, I would trust Intel the most, by far. Intel makes the CHIP!

Thanks for the info, really. It is absolutely the best tip I got here. “PureBasic” is only a collectible item for me from now on … Like QuickBasic, Basic PDS, VBDOS, Visual Basic — I paid for them more than what Intel charges upfront …
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 »

Zach:
I remember reading through a back issue of Run! (C64 Magazine) some code for a lottery program someone wrote. I'd always been fascinated with the idea, but assumed I'd never have the understanding to write something even marginally accurate.
Forget about it! PureBasic is ill-suited for lottery programming. “PureBasic” is, actually, an oxymoron: There is not Basic in it anymore! It should be called “Hybrid CBasic”. It looks a lot like C. And because C is so much more error-prone than Basic, C is ill-suited for lottery programming. Lottery requires a lot of logical constructs and it is very easy to make mistakes. I have made errors in my software but it has been easy to fix them. C would require a big programming team.

I believe the “Non-Pure Basic” team went too far in changing Basic. They removed all Basic statements and replaced them by C-like functions. Problem is, C uses far shorter names. Un-Pure Basic uses longer function names which definitely affect the performance. You won’t notice that in “Hello, world!” programs, but you will de definitely shocked in lottery programs. Lottery software checks millions and millions of combinations and prints them to screen or file. It is much faster to PRINT #1, than using the PureBasic cumbersome functions.

Actually, you can’t print directly to files. You must first create arrays and then dump them to file. Unfortunately, writing to an array uses the now hidden REDIM PRESERVE — one of the slowest commands of real (traditional) Basic. Do it for millions of iterations — you are out of time!

“PureBasic” should have preserved the traditional Basic statements that make really Basic … basic and easy to use. CLS, COLOR a,b, LOCATE X,Y, PRINT “text”, OPEN “filename” FOR INPUT/OUTPUT/APPEND, PRINT #n, a;b;c;d, etc. Of course, should have also offered the “PureBasic” commands (oops … functions!) — supposedly better-performing …

I offered free source code to generate lotto numbers (see the link in a previous post). Adapt it to “PureBasic”. Generate a few thousand 6/49 lotto combinations to file. Compare to the compiled program in PBCC. The 64-bit “PureBasic” is slower than the 32-bit PBCC. I thought the 64-bit would be faster by an order of magnitude! NOT!

This is a too-nerdy product. It will find a place in my collection only. Not for real use. The author of the PDF “book” is to be commended. But a non-Basic compiler like this needs a very big book for … Basic programmers!

Best of luck to you all, nerds, geeks and the like — I am one of you!
User avatar
skywalk
Addict
Addict
Posts: 4211
Joined: Wed Dec 23, 2009 10:14 pm
Location: Boston, MA

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

Post by skywalk »

Wow... :shock:
This nerd thinks you protest far in excess of any real knowledge of PureBasic. :?
And why would $1500 be of any concern to someone who can produce winning lottery numbers? :lol:
The nice thing about standards is there are so many to choose from. ~ Andrew Tanenbaum
Locked