Yes, I use g++ basically, whether in Linux or Windows.
Although, with the rational_calculator.cpp and integer_calculator.cpp, since they depend on the GMP library, when in Windows, I had to use Windows Linux Subsystem, so I don't have an actual Windows executable. I don't care. I grew tired of the all-too-enormous Visual Studio graphical interface a long time ago. I do most of my compiling with the GNU GCC collection of compilers.
For the two programs mentioned, I had to
build the GMP library locally then compile with something like:
g++ -lgmpxx lgmp -g rational_calculator.cpp -std=c++11 -o qc
I have a huge collection of my own command line math-related programs. In fact, one of the motivations for revisiting "high school" mathematics was to inspire me to spontaneously create algebra-related programs along the way, doing fundamental things that I would use frequently for the remainder of my days in this Bizarroland World, things like factoring numbers into prime factors, finding gcd and lcm, and a host of other operations ... reducing a matrix to row-reduced echelon form to solve systems of equations ... all kinds of useful programs inspired by the foundations and fundamentals.
By the way, Alex Stepanov (creator of Standard Template Library) said that
object-oriented programming is a hoax. C++ lends itself well to generic programming.
But, I am no expert … just an enthusiast and lifelong student.
OOP vs Generics : “Is” vs “Has” approach.If you have intentions of compiling the code itself, you will also need the little header file for error handling (from Bjarne Stroustrup). Place it in the same directory as the calculator.cpp files:
std_lib_facilities.hThe reason I altered it in the other versions was because I wanted to use it for probabilities, and I prefer rational numbers over decimal floating point (double). I needed the GMP library to deal with big factorials.
rational_calculator.cpp can handle things like: Combination of 4 elements taken 4 at a time times combination of 48 elements taken 9 at a time divided by combination of 52 eleements taken 13 at a time. In plain English, that is the probability of being dealt 4 of a kind in a 13 card hand.
> {(4C4)*(48C9)}/(52C13)
= 11/4165 = 0.00264106
> 2^3000
= 1230231922161117176931558813276752514640713895736833715766118029160058800614672948775360067838593459582429649254051804908512884180898236823585082482065348331234959350355845017413023320111360666922624728239756880416434478315693675013413090757208690376793296658810662941824493488451726505303712916005346747908623702673480919353936813105736620402352744776903840477883651100322409301983488363802930540482487909763484098253940728685132044408863734754271212592471778643949486688511721051561970432780747454823776808464180697103083861812184348565522740195796682622205511845512080552010310050255801589349645928001133745474220715013683413907542779063759833876101354235184245096670042160720629411581502371248008430447184842098610320580417992206662247328722122088513643683907670360209162653670641130936997002170500675501374723998766005827579300723253474890612250135171889174899079911291512399773872178519018229989376 = inf
> 180!
= 200896062499134299656951336898466838917540340798867777940435335160044860953395980941180138112097309735631594101037399609671032132186331495273609598531966730972945653558819806475064353856858157445040809209560358463319644664891114256430017824141796753818192338642302693327818731986039603200000000000000000000000000000000000000000000 = inf
Note that in C++, the basic built-in type representation can only handle 20! but not 21!
Notice how large the integers are that can be handled using the GMP library.
Note that the math behind 52C13 is (52!)/(13! * 39!) = (52*51*50*49*48*47*46*45*44*43*42*41*40)/(13*12*11*10*9*8*7*6*5*4*3*2*1)
I'm sure you have been exposed to combinations and permutations. I wanted to be able to type nCr into my command line calculator, and now I can. It's very satisfying to do so when it is one's own agenda and not at the request of a professor or "manager/boss/supervisor".